Cannot merge my list into a specific part of my code (python 3.3) -



Cannot merge my list into a specific part of my code (python 3.3) -

i cannot figure out how create tupil/list making when pick pizzas prints out, "you have picked pizzas, x, x,x ,x " have tried many times using tupil or list + loop.

i had used this,

selected_premium_pizzas = []; # list selected_premium_pizzas.append( x ); # x beingness pizza's numeric value

i cannot figure out how create loop through info , specify pizza type according pizza value.

for int in range(0,len(selected_premium_pizzas)): print( 'premium pizza, "' + premium_pizzas[selected_premium_pizzas[i]-1] + '", selected.' );

into code here,

num_pizzas = -1 while( num_pizzas <= 0 ) or ( num_pizzas > 5 ): try: num_pizzas = int( input( 'how many pizzas (max of 5):')) if num_pizzas =="": print("error cannot more 5") except: print('invalid input') pizza_dict = {"premium_pizza_price":8.50, "gourmet_pizza_price":13.50, "selected_pizzas":0, "num_premium_pizzas":0, "num_gourmet_pizzas":0} print('\n==premium pizzas==\n') in range (0,len(premium_pizzas)): print (str(i+1) + '. ' + premium_pizzas[i]) print('\n==gourmet pizzas==\n') in range (0,len(gourmet_pizzas)): print (str(i+1) + '. ' + gourmet_pizzas[i]) print('\nenter "next" move on.\n') while(true): if( num_pizzas == 0 ): break; try: selected = input('select premium pizza: ') if(selected == 'next'): break; else: selected = int(selected) if(selected<=0) or (selected > len(premium_pizzas)): print("invalid input") else: pizza_dict['num_premium_pizzas'] +=1 num_pizzas -=1 except: print("invalid input") print(' ') while(true): if( num_pizzas == 0 ): break; try: selected = input("select gourmet pizza: ") if(selected == "next"): break; else: selected = int(selected) if(selected<=0) or (selected > len(gourmet_pizzas)): print('invalid input') else: pizza_dict['num_gourmet_pizzas']+=1 num_pizzas -=1 except: print('invalid input')

you not writing exact error getting, problem in the

premium_pizzas[selected_premium_pizzas[i]-1]

part. premium_pizzas variable not declared in part of code listing, can't sure error is.

however, not clear trying achieve, list probable options. if want select pizzas in specific value range

selected = [pizza pizza in pizzas_dict if pizzas_dict[pizza] >= price_min , pizzas_dict[pizza] <= price_max]

in similar manner, if want select pizza part of name ('description')

selected = [pizza pizza in pizzas_dict if description in pizza]

if want user select pizzas 1,3,4 , homecoming values, dictionary not right structure, since not ordered, , should utilize list instead. however, there no point in doing such thing. user should select specific criterion, not arbitrary index number.

python python-3.x

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -