Search code examples
pythonlistuser-input

Display user choice from list


Hi I'm writing a program currently I'm pretty new to python,

what I'm wanting is for the user to select from two options like so

1. Easy Mode
2. Hard Mode

Solution

  • You set Choice = int(...), so Choice is still 1 or 2, so when you print it it'll show up as 1 or 2. Instead, you could set a variable mode depending on which if statement is entered:

    Choice = int(input("Select your difficulty: "))
    mode = "Invalid choice" # Set a default value
    
    if (Choice == 1):
      mode = "Easy Mode"
    elif (Choice == 2):
      mode = "Hard Mode"
    
    print ("Role: " , mode)
    

    Of course, this doesn't account for the case when the user's input isn't one of these choices, but that's a different question: Asking the user for input until they give a valid response