+ 2

What is the difference between first and second codes:

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

19th Aug 2017, 9:33 PM
IBRAHIM TAOFEEQ ADEBAYO
IBRAHIM TAOFEEQ ADEBAYO - avatar
1 ответ
+ 19
There is no difference. Their outputs are equal. The counter variable in the first code shouldn't have an indent by the way.
19th Aug 2017, 10:11 PM
Igor Makarsky
Igor Makarsky - avatar