Nov-21-2022, 10:17 AM
Morning all. Hope you are all well.
So I have recently started to learn python and i am a bit stuck.
I am working on a simple menu but for some reason, it just keeps looking even if i choose the option to quit (option 3).
Anyone able to tell me what I am doing wrong please? (Sorry i tried to use code snippet, but didn't work, hence "quote" instead, and hence the missing indentation)
Image attached...
Ok i found it... I need to convert the return value to an integer as the default is a string value and thus does not recognise the response as a correct value.
So I have recently started to learn python and i am a bit stuck.
I am working on a simple menu but for some reason, it just keeps looking even if i choose the option to quit (option 3).
Anyone able to tell me what I am doing wrong please? (Sorry i tried to use code snippet, but didn't work, hence "quote" instead, and hence the missing indentation)
choice = "0" def mainMenuChoice(): print("Please make a selection...") print("") print("1 - Option One") print("2 - Option Two") print("3 - Option Three (Quit)") menuChoice = input("Enter your choice: ") return menuChoice while choice != 3 : choice = mainMenuChoice() if choice == 1: print("You chose option 1") elif choice == 2: print("You chose option 2") quit()
Image attached...
Ok i found it... I need to convert the return value to an integer as the default is a string value and thus does not recognise the response as a correct value.