Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我的while循环不是';t为输入验证工作_Python_Validation_If Statement_While Loop - Fatal编程技术网

Python 我的while循环不是';t为输入验证工作

Python 我的while循环不是';t为输入验证工作,python,validation,if-statement,while-loop,Python,Validation,If Statement,While Loop,试试这个: 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
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
在检查多个条件时,您需要明确: 你不能说:
如果用户选择!='“是”或“否”
此处的“否”是导致错误的原因。您需要单独检查以下情况:

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 user_choice != 'no':