- 1
words = ["hello", "world", "spam", "eggs"] counter = 0 max_index = len(words) - 1 while counter <= max_index: word = words[
can anyone explain me the need of line no 5 i,e word=words[counter] in the above example in an easier way plz m a beginner
2 Respuestas
0
We iterate over a list. Word value will be hello at first iter, world at second iter... and so one.
0
Is the following line counter += 1 or counter = counter + 1?
If so whats happening is that
word = words[counter]
Counter will represent the index number starting from 0, index meaning the item number from the list...
Until it reached the length of that max_length variable an item from words will return to the variable word