response = {}
flag = True
while flag:
name = input("type your name:\t")
place = input("type place name that you most like:\t")
response[name] = place
repeat = input("anyone else? (yes/no)\t")
while repeat != 'yes' or repeat != 'no':
repeat = input("input wrong, please input again (yes/no)\t")
if repeat == 'no':
flag = False
print("______response___ __")
for name, value in response.items():
print(name+"\t favorite place is\t"+ place)
while repeat != 'yes' or repeat != 'no':这句代码有什么不对吗,为什么不管输入什么程序都进入while循环
当然有问题啊,你用的是或,比如我输入yes,它满足!=no,进入循环,然后一直循环。这里可以用if语句。
if repeat == 'no':
flag = false
else if repeat != 'yes'
print('')
大致意思就是这样子
while repeat != 'yes' or repeat != 'no':
改成
while repeat == 'yes' or repeat == 'no':
1,这个代码问题不少
2,这里没必要用while循环,只需if循环
3,解决方法可以是这样
如果是yes,,,continue如果是no,break
否则,input
懂了懂了,谢谢大佬们,自己现在在自学的确有很多东西不注意