List Comprehensions
Create lists efficiently using Python list comprehension.
Learn by experimenting
Study the Python code, run it, change values and observe the output. Practical experimentation is an important part of learning programming.
Python Code
Python runs directly in your browser.
numbers = [1, 2, 3, 4, 5] squares = [number * number for number in numbers] print(squares)
Python Output
Program output appears here.
Test your understanding
Choose the best answer.
Which function can calculate the length of a Python list?