Cannot fix/make this simple program (for loop)

This is the place for queries that don't fit in any of the other categories.

Cannot fix/make this simple program (for loop)

Postby ahmedruler1 » Tue Jun 10, 2014 12:57 am

So I'm making a pizza program where u get a list of pizzas they cost a certain price each and I have the list of pizzas in a list obv. I wanna use a for loop to print and create the inputs like for exampled here's what I have done and I cannot figure the rest out lol, please help me someone! I'm not allowed to use classes (my class to noob to know wat it is).
Code: Select all
premium_pizzas = 8.50
gourmet_pizzas = 5.00

def pizza_list():
#asks users how many pizzas they want (max 5)
    for i in range (0,len(premium_pizzas)):
        print (premium_pizzas[i])
     #I also wanted gourmet_pizza printed out as well...

Outcome:

show's pizza lists

1.Supreme Cheese
2.The Legendary pizza
3.Pentakill supreme
4.Teeto shroomo supreme
5.The volcanic rengar
6.Cheese and Ham
7.Vegetriano
$5 pizzas
8.Flame Gorrila
9.Snazzy chicken
10.Intergalactic BBQ
11.BBQ Chicken


#then user picks amount of pizzas they want by typing in the number next to the name.

#then at end it calculates the total amount


I've tried doing it like this but it simply doesn't wanna work! can someone elaborate and help me please?
Code: Select all
premium_pizzas = ["Supreme Cheese", "The Legendary pizza", "Pentakill supreme", "Teeto shroomo supreme", "The volcanic rengar", "Cheese and Ham" , "Vegetriano" ];
gourmet_pizzas = ["Flame Gorrila", "Snazzy chicken", "Intergalactic BBQ", "BBQ Chicken"]

premium_pizza_price = 8.50
gourmet_pizza_price = 5.00

customer_list = { "premium_pizzas":0, "gourmet_pizzas":0 }

print('==Premium Pizzas==\n')
for i in range (0,len(premium_pizzas)):
    print (str(i+1) + '. ' + premium_pizzas[i])
    num = -1;
    while(num<=0):
        num = input('How many ' + premium_pizzas[i] + 's would you like: ')
        if(num==0):
            break;
    customer_list["premium_pizzas"]+=num
print('\n==Gourtmet Pizzas==\n')
for i in range (0,len(gourmet_pizzas)):
    print (str(i+1) + '. ' + gourmet_pizzas[i])
    num = -1
    while(num<=0):
        num = input('How many ' + premium_pizzas[i] + 's would you like: ')
        if(num==0):
            break
    customer_list["gourmet_pizzas"]+=num
cost = (customer_list["premium_pizzas"]*premium_pizza_price)+(customer_list["gourmet_pizzas"]*gourmet_pizza_price);
print('\nTotal Cost: ' + str(cost))



Using python 3.3!
Last edited by stranac on Tue Jun 10, 2014 9:40 am, edited 2 times in total.
Reason: Removed "[python]" from title and locked OP. Fixed code tags.
ahmedruler1
 
Posts: 7
Joined: Tue Jun 25, 2013 6:29 am

Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 6 guests