List Comprehensions for Concise Loops in Python


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

Source Code

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