Skip to Content
Advanced Topics in Python
Comprehending Comprehensions

Good! Now let’s take another look at list comprehensions.

squares = [x ** 2 for x in range(5)]



Use a list comprehension to create a list, threes_and_fives, that consists only of the numbers between 1 and 15 (inclusive) that are evenly divisible by 3 or 5.

Folder Icon

Take this course for free

Already have an account?