I'm having a hard time understanding the following list comprehension:
words = [word for line in open('words.txt', 'r') for word in line.split()]
I understand the first part, the word for line in open('words.txt', 'r')
but the second part confuses me. Does it mean for each line in words.txt
, loop for each word
on the split line
?