Just a question about what can used in the for loop. From the lesson,
The general way of writing a for loop is:
for <temporary variable> in <list variable>:
<action>
Is “list” saying that the variable has to be a list type or is it casting the variable to a list? Couldn’t you use any thing you could iterate on like a range(x)?
the specification of what you iterate through is an expression, it does not need to be a list it does not need to be a variable it does need to be iterable
the variable is not temporary, it exists after the loop as well. it’s a variable, nothing special
“Why can’t we assign more than one word to the temporary variable?”
Remember a variable is like a box, the specific collection of symbols/characters is the label that tells us what’s in the box.
Each collection of symbols has a specific definition/purpose. By using a space you’re using two separate collections (aka words) that then require two separate definitions. Remember computers don’t speak english, they don’t know what a word (variable) means they just know that this collection of symbols refers to this other collection of symbols.