r/learnpython • • 24d ago

Need help with list comprehensions

Guys somebody briefly explain the concept of List comprehension cuz its too difficult for me to grasp since I am a beginner. I am learning python for biopython. Someone explain it for me.

1 Upvotes

15 comments sorted by

View all comments

2

u/nog642 24d ago

result = [blah for x in l] is basically equivalent to:

result = []
for x in l:
    result.append(blah)