Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.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_Python - Fatal编程技术网

为什么一直显示菜单?-python

为什么一直显示菜单?-python,python,Python,我试着做一些东西,如果你在m中输入,它会给你一个菜单,如果你只按enter键,它会继续 menu = False while True: option = input('Press M for menu, and press enter to continue') if option == 'm' or 'M': menu = True while menu: print('MENU') #there

我试着做一些东西,如果你在m中输入,它会给你一个菜单,如果你只按enter键,它会继续

menu = False
while True:
    option = input('Press M for menu, and press enter to continue')
    if option == 'm' or 'M':
        menu = True
        while menu:
            print('MENU')
            #theres some stuff here but thats not important
    else:
        print('Continuing...')
但是,每当我运行它时,它总是转到菜单屏幕

 if option == 'm' or 'M'
这里的
选项=='m'或'm'
是一个布尔表达式,它的计算结果始终为True,因为
'm'
将始终不是None。把它改成

if option.lower()=='m':

如果选项='m'或'm',请再次选中
。它将把
'M'
计算为True<代码>如果选项=='m'或选项=='m':