places= ["Home","In-n Out Burger", "John's house", "Santa Monica Pier", "Staples center", "LA Dodgers stadium", "Home"]
def placesCount(places):
multi_word = 0
count = 0
while True:
place = places[count]
if ' ' in place and place!='LA Dodgers stadium' **""" or anything that comes after LA dodgers stadium"""** :
multi_word += 1
if '' in place and place!='LA Dodgers stadium' """ **or anything that comes after LA dodgers stadium**""":
count += 1
print (count, "places to LA dodgers stadium"), print (multi_word)
placesCount(places)
在这种情况下,我基本上想知道当while循环到达列表的某个元素(“LA Dodgers Stadium”)时,如何阻止它添加到列表中。在到达列表的该元素后,它不应添加任何内容。我知道我以前问过这个问题,但我没有得到正确的答案。