0

I am trying to make something that gives you a menu if you enter in m, and continues if you just press 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...')

But, whenever I run this, it always goes to the menu screen.

  • 1
    check `if option == 'm' or 'M':` again. It will evaluate `'M'` as True. `if option == 'm' or option == 'M':` – Wisa Oct 29 '20 at 19:35

1 Answers1

0
 if option == 'm' or 'M'

Here option == 'm' or 'M' is a boolean expression which always evaluates to True, since 'M' will always be not None. Just change it to

if option.lower()=='m':
Abhinav Mathur
  • 7,791
  • 3
  • 10
  • 24