Skip to main content
Python Code Completion Easy +10 XP

List Comprehension

Complete the list comprehension for squares.

PythonFill in the blank
squares = [x**2 ___ x in range(5)]

Type the missing code

Show answer and explanation

Answer: for

List comprehensions use 'for' to iterate: [expression for variable in iterable].

Hint: Which keyword iterates in a comprehension?

What this challenge tests

Code Completion in Python: comprehension, basics.

Related challenges