Using while loops to count elements in a list
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. foreach would neaten it up places = ["Jack", "John", "Sochi"] count = 0 for place in places: if ' ' in place: multi_word += 1 if place == "Sochi": break count += 1 count=0 place =