places = ["Jack", "John", "Sochi"]
count=0
multi_word=0
place = places[count]
while place != "Sochi" and count < len(places):
if ' ' in place:
multi_word += 1
count += 1
place = places[count]
print ('Number of cities before Sochi:', count)
My code should print the number of cities before Sochi excluding Sochi . I don't understand what this line (place = places[count]) does, nor do I understand why I need it twice.
**place = places[count]**?placebefore used in the while loop.places.index('Sochi')which will return the index for the string 'Sochi' in the list and since lists are zero-indexed you'll get the sought after number