python无法跳出循环的

我在做一个练习,将键值输入字典。
每次用户用input输入键值对后询问是否再次输入。在判断是否的时候我希望如果希望继续输入用yes,反之输入no.如果输入不是yes或者no会提醒输入错误,重新输入。
但是我的代码在判断环节如果用户输入错误的时候,会进入无限提示输入错误循环,无法跳出。我看了半天无法发现错误,希望有前辈可以帮忙看一下

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)')
阅读 2.1k
1 个回答
    while repeat2!= 'yes' or 'no':
要改成
    while repeat2!= 'yes' and repeat2!='no':
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题