20.11 - List Comprehension (Advanced)
Enroll to start learning
You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.
Practice Questions
Test your understanding with targeted questions
Create a list of cubes for numbers 1-5 using list comprehension.
💡 Hint: Use `x**3` in the expression.
Generate a list of the first 5 letters of the alphabet.
💡 Hint: Use the `chr()` and `ord()` functions.
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What does the following list comprehension do: squares = [x*x for x in range(1, 6)]?
💡 Hint: Consider the effect of multiplying a number by itself.
True or False: List comprehensions can include conditions to filter items.
💡 Hint: Recall how filtering is done using conditions.
1 more question available
Challenge Problems
Push your limits with advanced challenges
Using list comprehension, create a list of tuples where the first element is a number from 1 to 5 and the second element is its cube.
💡 Hint: Think about how to format each item into a tuple.
Given a list of strings, create a new list with only the strings that have more than 3 characters using list comprehension.
💡 Hint: Compare the length of each word to 3.
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.