List Comprehensions in Python


Discover list comprehensions as a concise way to create lists by applying an expression to each item in a sequence.

Source Code

numbers = [1, 2, 3, 4]
doubles = [n * 2 for n in numbers]
print(doubles)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments