+ 2

For loop word [solved]

In the for loop lesson what context is ‘word’ being used?

26th Mar 2018, 4:31 PM
Martin Brock
Martin Brock - avatar
3 Answers
+ 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.
26th Mar 2018, 4:36 PM
Fata1 Err0r
Fata1 Err0r - avatar
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...
26th Mar 2018, 4:44 PM
HBhZ_C
HBhZ_C - avatar
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
26th Mar 2018, 7:44 PM
Ulisses Cruz
Ulisses Cruz - avatar