Python Forum
Noobie - IF and Else statement help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Noobie - IF and Else statement help
#4
Next time put your code between python tags using ctrl+shift+v or right mouse click>paste as plain text. You can get the python tags by clicking the little python logo from the tools from the post editor here.

This line - elif (UserChoice == 2) or (UserChoice == 3): - after the BreadChoise checking comes after else statement. The order of this conditional statements is if>elif>else. Also, are you sure you have to check for UserChoise not for BreadChoice?
If I change it with if, a MenuItem variable appears out of nothing. If a wrong item is chosen everywhere this variable is not defined at all but you want to print it. The same is for printing the messages for all of the choices before that - BreadChoice.
Output:
What would like from the menu?? 1. Eggs 2. Pancakes 3. Waffles 4. Oatmeal Please select a number between 1 and 4: 5 What bread would you like with your Eggs? 1. Wheat Toast 2. Sour Dough 3. Rye Toast 4. Pancakes Please select your bread type1 Traceback (most recent call last):   File "untitled.py", line 40, in <module>     print (" You have selected Wheat Toast with your ", MenuItem) NameError: name 'MenuItem' is not defined
At the bottom of the code, you have two else statements one after another. 

Put the code in python tags to provide the indentation because the logic in the code is missing. I indented the code just to work and it works.
Do not pay atention on my choices. I don't even know what is all of this.  Cool
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
Noobie - IF and Else statement help - by Jedi - Mar-18-2017, 05:55 AM
RE: Noobie - IF and Else statement help - by wavic - Mar-18-2017, 07:21 AM
RE: Noobie - IF and Else statement help - by Jedi - Mar-19-2017, 02:25 AM
RE: Noobie - IF and Else statement help - by wavic - Mar-19-2017, 03:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Noobie Python TypeError question zoid 4 8,061 Sep-01-2021, 02:28 PM
Last Post: zoid
  Noobie Question, Libreries on Intellij donjon 2 3,117 Dec-16-2017, 01:59 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020