# Trouble with assigning raw_input and simplicity

order_complete = False
num_pizzas = 0
num_wings = 0
num_drinks = 0
num_deserts = 0
pizza_price = 10
wing_price = 8
desert_price = 5
drink_price = 2
pizza_total = pizza_price * num_pizzas
wing_total = wing_price * num_wings
drink_total = drink_price * num_drinks
desert_total = desert_price * num_deserts
order_total = pizza_total+wing_total+desert_total+drink_total

name = raw_input("Hello! What is your name? ")
print "Hello %s, what would you like to order? " % name

while order_complete == False:
order = raw_input("You can press 1 for Pizza, 2 for Wings, 3 for Desert, 4 for Drinks, or 5 for done ")
if order == â€ś1â€ť:
num_pizzas = raw_input("Ok, how many pizzas would you like to order? ")
print "Ok, you ordered %s pizzas. What else would you like to order? " % num_pizzas
elif order == â€ś2â€ť:
num_wings = raw_input("Ok, how many wings would you like to order? ")
print â€śOk, you ordered %s wings, what else would you like to order?â€ť % num_wings
elif order == â€ś3â€ť:
num_deserts = raw_input("Ok, how many deserts would you like to order? ")
print "Ok, you ordered %s deserts, what else would you like to order? " % num_deserts
elif order == â€ś4â€ť:
num_drinks = raw_input(â€śOk, how many drinks would you like to order?â€ť )
print "Ok, you ordered %s drinks, what else would you like to order? " % num_drinks
elif order == â€ś5â€ť:
order_complete == True
print â€śOk, you ordered %s pizzas, %s wings, %s deserts, %s drinks, bringing your total to %s. Thanks for ordering!â€ť % str(num_pizzas), str(num_wings), str(num_deserts), str(num_drinks), str(order_total)

It then throws this error:
Traceback (most recent call last): File â€śpythonâ€ť, line 35, in <module> TypeError: not enough arguments for format string

Iâ€™m not 100% sure what that means? Any help would be appreciated.

Also, did I format the code in the simplest manner, or is there a better way to structure the syntax?

Update: Adding parenthesis around the final % function fixed the issue.

However, now this problem comes up;
Ok, you ordered 0 pizzas, 0 wings, 0 deserts, and 0 drinks, bringing your total up to 0. Thanks for ordering!
You can press 1 for Pizza, 2 for Wings, 3 for Desert, 4 for Drinks, or 5 for done

even though it should have updated order_complete to being True, and it didnâ€™t update the num_pizzas/wings/etc as a counter, and is returning 0 for the totals.

Any idea why?

Because here in your last elif:

youâ€™re using the comparison operator `==` which isnâ€™t assigning `True` to `order_complete` at all, which will just make the `while` loop keep on going.

Quick explanation:

`order_complete == True` will just keep comparing itself (itself being `False`) with `True`, which will result in being `False`, which will keep the loop ongoing.

I hope that makes sense.

1 Like

Gotcha! So it should just be one = sign to update it, ty!

Any idea why the counters werenâ€™t being stored?

Itâ€™s because youâ€™re formatting past the amount of just one argument, so parentheses were needed to contain more arguments, if that makes sense.

1 Like

That does! However, after I updated the arguments with a second set of parenthesis, the counters still arenâ€™t updating. Iâ€™m at a loss for why

I think I got a bit confused. Iâ€™m busy doing multiple things, so I got mixed up with my previous answer above. Sorry, my bad .
Well did you input anything when it asked you to? I ran the code myself and it stores things just fine and works.

1 Like

No problem, I appreciate the time youâ€™re taking to help

I did, still didnâ€™t update. Iâ€™ll try again when I get home to see what needs fixing!

1 Like

Some ideas to toss aroundâ€¦

Those would be more useful as functions so they can be called to compute any order and return total price.

Also, a small data structure will cater to the functionality:

``````prices = {
'pizza': 10.00,
'wings': 8.00,
'dessert': 5.00,
'drink': 2.00
}

def calculate_item_total(item, quantity):
return prices[item] * quantity
``````

The order could also be data structure:

``````order = {
'pizza': None,
'wings': None,
'dessert': None,
'drink': None
}``````
2 Likes

@codinghawk the loop ends after adjusting the last elif, thank you! I tried running it again, and it still isnâ€™t saving the variable counters. Are you running it in codeacademy, or a different compiler? Iâ€™m not 100% sure what Iâ€™m doing wrong

Here is exactly what is printing to console (so you can see Iâ€™m using the selections);

Hello! What is your name? Phillip
Hello Phillip, what would you like to order?
You can press 1 for Pizza, 2 for Wings, 3 for Desert, 4 for Drinks, or 5 for done 1
Ok, how many pizzas would you like to order? 12
Ok, you ordered 12 pizzas. What else would you like to order?
You can press 1 for Pizza, 2 for Wings, 3 for Desert, 4 for Drinks, or 5 for done 5
Ok, you ordered 0 pizzas, 0 wings, 0 deserts, and 0 drinks, bringing your total up to 0. Thanks for ordering!

@mtf I havenâ€™t made it to the dictionary module yet, so that is a bit beyond what I can currently do. But, Iâ€™m guessing you would use that instead of order_total, and can replace the var throughout with prices[item] to get the same call results?

2 Likes

Exactly, a single purpose function that can work on multiple inputs with expected output given the input.

When you reach data structures and their methods return to this topic so we can play it out.

2 Likes

I ran it on repl.it. Odd if itâ€™s not working on the Codecademy lesson itself. Iâ€™ll try it on the lesson page tomorrow and see how it works.

1 Like

Is this piece of code still above the while loop? It should be after the while loop.

1 Like

I tried to replace the coding after the loop, and Iâ€™m getting all sorts of crazy errors in the codeacademy compiler. I think, at this point, it would be best to scrap the code and perhaps try it using the method you described. Once I get to that point, Iâ€™ll attempt to re-write it and go from there. I may have let my ambition outrun my knowledge on this one lol.

Thank you, again, for the feedback and suggestions. I certainly appreciate it!

Youâ€™re welcome. Never did ask, is this an actual CC project? If so, please post a link to the exercise page. Thanks.

No sir, someone suggested coming up with projects as I do the courses to help me learn to code better, and develop better critical thinking habits. Was just a random idea I thought I could do, but looking back perhaps sticking to the curriculum would be a better route.

1 Like

Thereâ€™s no sin in stepping away while you upgrade your skills. You can always come back, and should. Looping back over material and projects is how we grow intuition. Gradually we begin to visualize, and then weâ€™re off to the races. It all takes time. I do agree that staying the course of the module path is a good plan. Weâ€™ll pick this up later, Iâ€™m sure.

2 Likes