所以这就是我正在努力的。我想要“是”和“否”等于相同的事物并结束循环(我还没有开始),但是当输入的内容不是“是”或“否”时,它会再次循环问题,直到输入yes或no。我很难找出如何做到这一点,我仍然在学习,而循环对我来说是新的领域。循环选择题?
我使用的是2.7
d1 = raw_input('Please answer with Yes or No.\n')
if d1 == 'Yes':
print('Good, let\'s begin.')
elif d1 == 'No':
print('Good, let\'s begin.')
if d1 == 'yes':
print('Good, let\'s begin.')
elif d1 == 'no':
print('Good, let\'s begin.')
else:
ps('Mmmmm...')
你确定它是Python2.7吗?因为Python3中的print()。但是你使用raw_input - 它来自Python2.7 – AndMar
从Python 2.7.4开始,你可以在括号中使用'print()',就像在python 3.x中一样 – MUYUM
'from __future__ import print_function'是隐含的。 –