SHARE
TWEET

#3 Shopping List flazacros

a guest Jul 15th, 2019 137 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shoppingList= []
  2. def showMenu():
  3.     print("Welcome to the shopping list program ")
  4.     print("""
  5. Menu
  6.  n - New shopping list item
  7.  d - Display shopping list
  8.  e - Edit an item in the list
  9.  c - Check or remove item from list
  10.  ? - Display this menu
  11.  q - Quit program
  12. """)
  13.  
  14. def showList():
  15.     print('{:*^30}'.format(' Shopping List '))
  16.     for number,item in enumerate(shoppingList):
  17.         print('{:<}'.format('*'), end='')
  18.         print('{} {:<26}'.format(number+1,item), end='')
  19.         print('{:>}'.format('*'))
  20.     print('{:<}'.format('*'), end='')
  21.     print('{:>29}'.format('*'))
  22.     print('{:*^30}'.format('*'))
  23.  
  24.  
  25. def addToList(newItem):
  26.     shoppingList.append(newItem)
  27.  
  28. def checkItem():
  29.     itemX= input("What item do you wish to check?: ")
  30.     i=int(itemX)
  31.  
  32.     shoppingItem = shoppingList[i-1]
  33.     if i > len(shoppingList) :
  34.         print("Error: There is no item at that position")
  35.         pass
  36.     else:
  37.         del shoppingList[i-1]
  38.         print("Item {} was sucessfully removed" .format(itemX))
  39.         pass
  40.  
  41.     # for itemX in shoppingList:
  42.     #     del shoppingList[i]
  43.     #     print("Item {} was sucessfully removed" .format(itemX))
  44.     # else:
  45.     #     print("Error: There is no item at that position")
  46. """
  47. def editItem():
  48.   eitem= in(input("What item do you wish to edit?: "))
  49.   shoppingList.remove(ritem)
  50. """
  51. showMenu()
  52.  
  53. while True:
  54.     command= input(" ")
  55.     if command== "n":
  56.         newItem= input("Enter new Item: ")
  57.         addToList(newItem)
  58.         continue
  59.     elif command== "q":
  60.         showList()
  61.         print("Goodbye!")
  62.         break
  63.     elif command== "?":
  64.         showMenu()
  65.         continue
  66.     elif command== "d":
  67.         showList()
  68.         continue
  69.     elif command== "c":
  70.         checkItem()
  71.         continue
  72.     elif command== "e":
  73.         editItem()
  74.         continue
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top