Nov-21-2022, 10:17 AM
(This post was last modified: Nov-21-2022, 10:43 AM by Larz60+.
Edit Reason: Change 'quote' tags to 'python' tags
)
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.
Larz60+ write Nov-21-2022, 10:45 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please use bbcode (python) code tags, rather than attachments.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please use bbcode (python) code tags, rather than attachments.