0

working on my python assessment and i cant get my function to do anything apart from continuously show itself. It wont exit or move on to the next function Sorry if this is a bit silly but I don't really know what to do or how to describe the problem

    def main_menu():          
    menu_choice = input("""
---------------------------------------
Welcome to the GCSE Celebrity Dogs Game
 Please choose an option from the menu
---------------------------------------
1) Play the game
2) Quit
""")
    if menu_choice == 1:
     deck_choice()
    elif menu_choice == 2:
     print("Exiting game.....")
     quit()
    else:
     main_menu()


correct_numbers = [6,8,10,12,14,16,18,20,22,24,26,28,30]


def deck_choice():
    num_cards = input("""
How many cards owuld you liek to play with?
**Please note this must be a number between 4 and 30 and cannot be odd**
""")
    if num_cards not in correct_numbers:
        print("Sorry, that number isnt valid. Please enter another number")
    else:
        return num_cards


main_menu() 
L3Cache
  • 13
  • 1
  • 1
    Your indentation makes little sense. This isn't valid Python. Paste your code exactly as it is, select it, and then use the code button in the question editor to format it properly. This is especially important in Python with its significant white space. – John Coleman Mar 17 '19 at 12:05

1 Answers1

0

You need to either cast the menu_choice to int so you can compare it with an int or cast the int to a string in the if statement.

For example, to cast the input to an int:

menu_choice = input("""your menu""")

if int(menu_choice) == 1:
    # do stuff

Alternatively, cast int to string:

menu_choice = input("""your menu""")

if menu_choice == str(1):
    # do stuff
Brendan Martin
  • 561
  • 6
  • 17