quitshop = False shoppinglist = ['Carrots', 'Potatoes', 'Onions' ] while (quitshop == False): #added in to keep refreshing the menu after an action is made/input is made print (" ") print ("menu") print (" ") print ("1 = add item to list") print ("2 = remove an item from list") print ("3 = view list") print ("4 = quit program") userchoice = int(input ("What would you like to do?: ")) if (userchoice ==1): additem = input ("Please enter an item to be added: ") shoppinglist.append(additem) elif (userchoice ==2): userdel = input("What would you like to delete? (Case Sensitive): ") if userdel in shoppinglist: shoppinglist.remove(userdel) print ("You got it, Chief! Deleting that item") else: print ("I'm sorry but that's not in the list.") #I enjoy my programs being a smarty pants #added in to keep from breaking elif (userchoice ==3): print ("Here's your list, bud:") print (shoppinglist) elif (userchoice ==4): print ("Seeya!") quit quitshop = True #wish I had known that the command for quitting was actually called quit on the last assignment else: print ("Error") print ("Wanna try again?")
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