List Comprehensions for Efficient Loops in Python


Generate new lists by applying an expression to each item in a sequence.

Source Code

squares = [x ** 2 for x in range(10)]
print(squares)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments