python - How to sucsessfully ask the user to choose between two options -


new programmer here

i'm trying ask user choose between 2 options can't right.

inp = int(input()) while inp != 1 or inp != 2:     print("you must type 1 or 2")     inp = int(input()) if inp == 1:     print("hi") if inp == 2:     print("ok")     quit() 

even if enter 1 or 2 when ask still spits "you must must type 1 or 2"

my end goal if enter 1, continue program while if choose 2 end program. help.

just work strings. if need turn "inp" variable integer, don't wrap int() function around input(), wrap variable (i.e. int(inp) ). also, change ors ands:

inp = "" while inp != "1" , inp != "2":     inp = input("enter 1 or 2: ")     if inp != "1" , inp != "2":         print("you must type 1 or 2")  if inp == "1":     print("hi") if inp == "2":     print("ok") 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -