python - How to join strings together within a list? -


my task following

write menu online food service option of 4 different cuisines ie: mexican

each of cuisines should have @ least 5 different choices such curry curry sauce hot curry , on. should print out users final order order number.

my question how had order , join of string in list example: add hot veg curry puts in different order

lastly make code efficient should use def function? current code. import random

            print("welcome hungry horse...")             print("we have wide range of food choice around world")             print("we have food choices from: indian / italian / chinese / mexican")             foodlist = ([])              drinkcho = input("lets start drinks. state if drinks yes or no").lower()             if drinkcho == "yes":                 drinkcho2 = input("which drink want? have option of:coke / fanta / cobra / water / fruitshoot").lower()                 if drinkcho2 == "coke":                             foodlist.insert(1,drinkcho2)                             print("you have chosen coke.a great choice")                 if drinkcho2 == "fanta":                             foodlist.insert(2,drinkcho2)                             print("you have chosen fanta.a great choice")                 if drinkcho2 == "cobra":                             foodlist.insert(3,drinkcho2)                             print("you have chosen cobra.a great choice")                 if drinkcho2 == "water":                             foodlist.insert(4,drinkcho2)                             print("you have chosen water.a great choice")                 if drinkcho2 == "fruitshoot":                             foodlist.insert(5,drinkcho2)                             print("you have chosen fruitshoot.a great choice")              elif drinkcho == 'no':                 print("ok no problem lets move on staters")             maincho = input("which type of mains like:indian / italian / chinese / mexican").lower()             if maincho == "indian":                     print("get ready enticed rich spicy falvors of indian cusine")                     indcho = input("what order: curry / onion bhaji / samosa")                     if indcho == "curry":                             foodlist.insert(indcho)             currycho = input("what curry  like: chicken curry / lamb curry/  veg curry")             if currycho == "veg curry":                         print("thats excellent choice")                         foodlist.insert(6,currycho)             elif currycho == "lamb curry":                         print("thats excellent choice")                         foodlist.insert(7,currycho)             elif currycho == "chicken curry":                         foodlist.insert(8,currycho)                         print("thats excellent choice")             else:                 print("inncorrect input")                 currycho = input("what curry  like: chicken curry / lamb curry/  veg curry")                 foodlist.insert(currycho)              indside = input(str("what want eat delicious curry naan bread / rice or both"))             if indside == "naan bread":                 foodlist.insert(9,indside)             elif indside == "rice":                 foodlist.insert(10,indside)             elif indside == "both":                 foodlist.insert(11,indside)             spicean = input("how spicy curry be:hot/medium/mild").lower()             if spicean == "hot":                 print("ooh must man!")                 foodlist.insert(12,spicean)             elif spicean == "medium":                 print("that safe option")                 foodlist.insert(13,spicean)             elif spicean == "mild":                 ("you don't seen spicy food!")                 foodlist.insert(14,spicean)              rnd = (int(random.randrange(100)) + 1)              print ("your final order", foodlist ," order number is", rnd, "please wait until process order") 

to add items end of list, want use

foodlist.append(choice); 

this way don't need worry indexing involved .insert().

that means either have rearrange if statements or better acquainted insert(): https://docs.python.org/2/tutorial/datastructures.html


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -