1

I am probably overlooking something very simple here but for some reason when i run this block of code, it will only ask for the menu_selection var, it will not ask for input from any of the if cases

import user

print("1.) Login")
print("2.) Register")
print("3.) Exit")

menu_selection = input("Selection:")

if menu_selection == 1:
    username = input("Enter username:")
    password = input("Enter password:")
    login_user = username, password

elif menu_selection == 2:
    username = input("Enter username:")
    password = input("Enter password:")
    new_user = user.User(username, password)

elif menu_selection == 3:
    exit("PyMess closed.")

1 Answer 1

2

Because the result stored in menu_selection will be a string - as that is the return type of input. Make it an int.

menu_selection = int(input("Selection:"))

Note that this will fail if you enter a non-integer value when you run the program.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.