0

I can't understand this while loop please someone explain me how it'll work?

words = ["hello", "world", "spam", "eggs"] counter = 0 max_index = len(words) - 1 while counter <= max_index: word = words[counter] print(word + "!") counter = counter + 1

23rd Oct 2018, 7:30 AM
Prince
Prince - avatar
1 ответ
+ 1
max_index = 3 as long as counter is smaller than 3 it stays true then an element with the index of the value of counter will be assigned to word the current word will be printed with an exlamation mark and the counter will be increased by one this continues for all elements in words understandable?
23rd Oct 2018, 7:43 AM
Mbrustler
Mbrustler - avatar