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
Post a Comment