0
What is word in words
Where exactly does the variable word come from? It doesn't match words
2 Respostas
+ 7
In a for loop, you go through an array of things (like a list of words or a string of characters) one element at a time. You need to temporarily give the elements a name so that you can do something with them. You can use any name you want, but descriptive names are preferred to help the reader understand what's going on. "for word in words" and "for char in string" are common, but if you wanted to say "for x in words" or "for potato in words", they would work just as well. 🙂
+ 2
That means we iterate through words, using word variable.
If we have a words list assigned ["Solo, "Learn", 42]
for word in words will loop 3 times. Each time word is an element of words. 1st time word is "Solo", 2nd time is "Learn", and 3rd time is 42.