在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/Python/ python無(wú)法跳出循環(huán)的

python無(wú)法跳出循環(huán)的

我在做一個(gè)練習(xí),將鍵值輸入字典。
每次用戶用input輸入鍵值對(duì)后詢問(wèn)是否再次輸入。在判斷是否的時(shí)候我希望如果希望繼續(xù)輸入用yes,反之輸入no.如果輸入不是yes或者no會(huì)提醒輸入錯(cuò)誤,重新輸入。
但是我的代碼在判斷環(huán)節(jié)如果用戶輸入錯(cuò)誤的時(shí)候,會(huì)進(jìn)入無(wú)限提示輸入錯(cuò)誤循環(huán),無(wú)法跳出。我看了半天無(wú)法發(fā)現(xiàn)錯(cuò)誤,希望有前輩可以幫忙看一下

sign=True
while sign:

a=input('plz enter your name: ')
b=input('plz enter your favourite mountain: ')
responses[a]= b
repeat=input('anyone else would like to type the inf? (yes/no)')
if repeat=='no':
    sign=False
elif repeat=='yes':
    sign=True
else:
    print('invalid typing,try again')
    repeat2=input('anyone else would like to type the inf? (yes/no)')
    while repeat2!= 'yes' or 'no':
        print('invalid typing,try again')
        repeat3=input('anyone else would like to type the inf? (yes/no)')
回答
編輯回答
負(fù)我心
    while repeat2!= 'yes' or 'no':
要改成
    while repeat2!= 'yes' and repeat2!='no':
2017年11月11日 23:54