Can anyone plz fix this error? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Can anyone plz fix this error?

# 🚨 Don't change the code below 👇 print("Welcome to Python Pizza Deliveries!") size = input("What size pizza do you want? S, M, or L ") add_pepperoni = input("Do you want pepperoni? Y or N ") extra_cheese = input("Do you want extra cheese? Y or N ") # 🚨 Don't change the code above 👆 #Write your code below this line 👇 bill=0 if size ==S: bill = 15 print ('Small pizza is for $15 ') if add_pepperoni ==Y: bill += 2 elif size ==M: bill = 20 print ("Medium pizza is for $20") if add_pepperoni ==Y: bill += 3 elif size ==L: bill = 25 print('Large pizza is for $25') if add_pepperoni==Y: bill += 3 if extra_cheese ==Y: bill += 1 print(f'Your total bill is ${bill}')

14th Aug 2021, 3:50 AM
Saurabh
4 ответов
+ 3
try putting S, M, and L in quotes. like: if size == 'S': ...
14th Aug 2021, 3:53 AM
Slick
Slick - avatar
+ 1
"Y" has to be in quotation marks in all if statements, too.
14th Aug 2021, 4:02 AM
Simon Sauter
Simon Sauter - avatar
0
# Welcome message with menu and price list print(""" Welcome to NCAIR's pizza place :) Let us take your order: Menu and price list>>> Sizes; Small pizza : $15 Medium pizza : $20 Large pizza : $25 Condiments and extras; Pepperoni for small pizza : +$1 Pepperoni for medium or large : +$2 Extra cheese for any pizza : +$1 PLACE YOUR ORDER.. """) # Ask for pizza size pizzaSize = input(""" Enter the size of pizza you would like to order "S" for small size "M" for medium size "L" for large size """).lower() # Calculate initial bill based on pizza size if pizzaSize == "s": bill = 15 elif pizzaSize == "m": bill = 20 elif pizzaSize == "l": bill = 25 else: print("Invalid input. Please try again.") exit() # Ask if user wants toppings and condiments toppings = input("Would you like to add toppings and condiments? (yes or no) ").lower() # Provide options for toppings and update b
17th Sep 2023, 7:26 PM
Gideon Joseph
Gideon Joseph - avatar
- 1
Saurabh You're comparing it with an undeclared variable. Try putting Y, S, M and L in quotes so that you're comparing size with a string.
14th Aug 2021, 4:45 AM
Calvin Thomas
Calvin Thomas - avatar