Python for Everybody - Comparing and Sorting Tuples

Tell us what’s happening:
im not having any issues with the course, i just want to understand this little quirk with
“list comprehension”.

all the answers in the quiz and even the video had this little tuple before the for loop, what does it mean and how does it work? and where did it first get declared: the for loop or the little tuple?

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0

Challenge: Python for Everybody - Comparing and Sorting Tuples

Link to the challenge:

i watched the video again and im pretty sure i get it now, what really confused me is that the tuple was before the for loop rather than after it, imo it makes infinitly more sense to put the tuple after the for loop, is that possible?

I think I had the same problem understanding list comprehensions. It’s in the opposite order of the for loop. You understand a for loop as

for this item in this collection:
do this output

but the list comprehension is in the opposite order:
do this output for this item in this collection

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.