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

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

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

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)')
回答
編輯回答
負我心
    while repeat2!= 'yes' or 'no':
要改成
    while repeat2!= 'yes' and repeat2!='no':
2017年11月11日 23:54