我在运行Python 3.5.0的Windows8中有一个流程图问题,当我运行程序时,没有错误信息,但当我键入no时,程序执行输入为yes,您可以帮助我解决这个问题。
print('Hello, do you want to play a game')
print('Great lets play a guessing game')
print('Think of an animal and I will ask you')
print('different questions to try to guess your animal')
print('Press Y for yes and N for no')
fly = input('Question #1 Can your animal fly?')
if fly == 'Y':
print('You have chosen no')
bird = input('Question #2 Is your animal a bird?')
if bird == 'Y':
print('Yay I win')
elif fly == 'N':
print('Question #2 Can your animal swim?')
elif bird == 'N':
print('Does your animal live on land')发布于 2017-08-13 12:40:47
答案很简单,你已经写过
if fly == 'Y':
print('You have chosen no')显然你的意思是
if fly == 'N':
print('You have chosen no')要找出这种类型的拼写错误,请毫不犹豫地在代码中添加print语句,或者大声向某个橡皮鸭解释代码,这真的很有帮助!
https://stackoverflow.com/questions/45656042
复制相似问题