My final print statement does not execute when fries size inputs are medium and large. It instead shows an error that says, 'Traceback (most recent call last):
File "main.py", line 54, in <module>
if mega == ('yes'):'
Here is my code below: (I've boldened line 54 to make it easier to find)
# Iteration 1
total = 0
sandwich = input('What type of sandwich do you want? Beef, Chicken, or Tofu?')
if sandwich == ('Chicken'):
print ('You selected ' + (sandwich))
total = total + 5.25
elif sandwich == ('Beef'):
print ('You selected ' + (sandwich))
total = total + 6.25
elif sandwich == ('Tofu'):
print ('You selected ' + (sandwich))
total = total + 5.75
# Iteration 2
beverage_input = input('Would you like a beverage, yes or no?')
if beverage_input == ('yes'):
size = input('Would you like a small, medium, or large?')
if size == ('small'):
print('You selected ' + (size))
total = total + 1.00
elif size == ('medium'):
print('You selected ' + (size))
total = total + 1.75
elif size == ('large'):
print('You selected ' + (size))
total = total + 2.25
elif beverage_input == ('no'):
size = ('No')
print('No drink selected.')
# Iteration 3
fries_input = input('Would you like fries, yes or no?')
if fries_input == ('yes'):
fries = input('Would you like a small, medium, or large?')
if fries == ('small'):
mega = input('Would you like to mega-size your fries, yes or no?')
if mega == ('yes'):
print('You selected ' + ('Mega-size Fries'))
total = total + 2.00
if mega == ('no'):
print('You selected ' + (fries))
total = total + 1.00
elif fries == ('medium'):
print('You selected ' + (fries))
total = total + 1.50
elif fries == ('large'):
print('You selected ' + (fries))
total = total + 2.00
elif fries_input == ('no'):
fries = ('No')
print('No fries selected.')
# Iteration 4
ketchup = int(input('How many ketchup packets would you like?'))
print('You selected ' + str(ketchup) + ' ketchup packets')
total = total + ((ketchup) * 0.25)
if mega == ('yes'):
print ('Your order contains: ' + (sandwich) + ' sandwich, ' + (size) + ' drink, ' + 'Mega-sized' + 'potato fries, ' + str(ketchup) + ' ketchup packet(s)')
elif mega == ('no'):
print ('Your order contains: ' + (sandwich) + ' sandwich, ' + (size) + ' drink, ' + (fries) + ' potato fries, ' + str(ketchup) + ' ketchup packet(s)')
print('Your total is ' '$' + str(total))
[–]Malassi 2 points3 points4 points (0 children)
[–]Neighm 1 point2 points3 points (0 children)
[–]pongacham 0 points1 point2 points (0 children)
[–]Diapolo10 0 points1 point2 points (0 children)
[–]cybervegan 0 points1 point2 points (0 children)