我有一个代码或停止循环,我不知道该怎么做
ciao = "revoir bye see you"
ciao = ciao.lower().split()
quests = "revoir mam bak kio"
quests = quests.lower().split()
while 1:
for i in range(len(quests)):
if quests[i] in ciao:
break
print('khvb')
答案 0 :(得分:2)
您的问题不清楚。
中断只会停止for循环,如果您希望它停止while循环,则可以考虑以下内容:
ciao = "revoir bye see you"
ciao = ciao.lower().split()
quests = "revoir mam bak kio"
quests = quests.lower().split()
should_continue = True
while should_continue:
for i in range(len(quests)):
if quests[i] in ciao:
should_continue = False
break
print('khvb')
``