#l = [] #l.append('Egg',1,12) #l.append('Bagel',1,13.95) #l.append('Toast',1,14) #l.append('Coffee',1,100) #l.append('Orange juice',1,30) #l.append('Chocolate milk',1.5,50) #l.append('Milk',1,50) l = ['Egg',1,12,'Bagel',1,13.95,'Toast',1,14,'Coffee',1,100,'Orange juice',1,30,'Chocolate milk',1.5,50,'Milk',1,50] name = raw_input('Would you like to see a menu or have you decided to order an item?\n') od = name.split() option = od[0] if 'Order' in option.capitalize(): item = od[1] if 'Menu' in option.capitalize(): print l[::3] elif 'Order' in option.capitalize() and item.capitalize() in l: c= l[(l.index(name.capitalize().lstrip('Order').lstrip().capitalize())+1)] d= l[l.index(name.capitalize().lstrip('Order').lstrip().capitalize())] print "Here is your "+str(d)+". That will be $"+str(c)+", please!\n" l[(l.index(item.capitalize())+2)] = (l[(l.index(item.capitalize())+2)]-1) else: print "You need to enter a valid 'order' or look at the 'menu'.\n" #try: # d #except NameError: # d = 'placeholder' #if d in l: #else: # print "We don't have that item" #else: # c= l[(l.index(name.capitalize())+1)] # d= l[l.index(name.capitalize())]
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question