end_program = False
while end_program == False:
user_choice = input('\nWould you like to play a game?\n Please pick yes or no\n').lower()
if user_choice != 'yes' or 'no':
print('You didn\'t pick yes or no...try again please\n')
end_program = False
else:
end_program = True
答案 0 :(得分:0)
尝试一下:
end_program = False
while end_program == False:
user_choice = input('\nWould you like to play a game?\n Please pick yes or
no\n').lower()
if user_choice != 'yes' or user_choice !='no':
print('You didn\'t pick yes or no...try again please\n')
end_program = False
else:
end_program = True
在检查多个条件时,您需要具体说明:
你不能说:
if user_choice!= 'yes' or 'no'
在此处使用“否”会导致错误。您将需要单独检查条件:
if user_choice != 'yes' or user_choice != 'no':