+ 2
For loop word [solved]
In the for loop lesson what context is ‘word’ being used?
3 Respuestas
+ 2
I'm not sure. You didn't supply context either.
What's the example from the lesson? I'll be more than happy to explain it.
0
As any other identifier's name ,you can use any word you want to access the iterable list
for e in words:
print(e)
'word' is just an arbitrary name to mean for elements in the list words...
0
I believe this is the lesson you are talking about:
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2435/
EDITED:
this is the code, I believe (I've added comments for explanaition):
words = ["hello", "world", "spam", "eggs"] # created a list with 4 strings in it
for word in words: # in every iteration of the loop the variable word is assigned one item (string) from words, like this:
# word = "hello", word = "world", word = "spam", word = "eggs"
print(word + "!") # print the value in word followed by a "!" in every iteration of the loop