# 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