Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python List Comprehension

# List comprehension for the squares of all even numbers between 0 and 9
result = [x**2 for x in range(10) if x % 2 == 0]

print(result)
# [0, 4, 16, 36, 64]
Source by www.codecademy.com #
 
PREVIOUS NEXT
Tagged: #Python #List #Comprehension
ADD COMMENT
Topic
Name
3+7 =