Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shoppingList= []
- def showMenu():
- print("Welcome to the shopping list program ")
- print("""
- Menu
- n - New shopping list item
- d - Display shopping list
- e - Edit an item in the list
- c - Check or remove item from list
- ? - Display this menu
- q - Quit program
- """)
- def showList():
- print('{:*^30}'.format(' Shopping List '))
- for number,item in enumerate(shoppingList):
- print('{:<}'.format('*'), end='')
- print('{} {:<26}'.format(number+1,item), end='')
- print('{:>}'.format('*'))
- print('{:<}'.format('*'), end='')
- print('{:>29}'.format('*'))
- print('{:*^30}'.format('*'))
- def addToList(newItem):
- shoppingList.append(newItem)
- def checkItem():
- itemX= input("What item do you wish to check?: ")
- i=int(itemX)
- shoppingItem = shoppingList[i-1]
- if i > len(shoppingList) :
- print("Error: There is no item at that position")
- pass
- else:
- del shoppingList[i-1]
- print("Item {} was sucessfully removed" .format(itemX))
- pass
- # for itemX in shoppingList:
- # del shoppingList[i]
- # print("Item {} was sucessfully removed" .format(itemX))
- # else:
- # print("Error: There is no item at that position")
- """
- def editItem():
- eitem= in(input("What item do you wish to edit?: "))
- shoppingList.remove(ritem)
- """
- showMenu()
- while True:
- command= input(" ")
- if command== "n":
- newItem= input("Enter new Item: ")
- addToList(newItem)
- continue
- elif command== "q":
- showList()
- print("Goodbye!")
- break
- elif command== "?":
- showMenu()
- continue
- elif command== "d":
- showList()
- continue
- elif command== "c":
- checkItem()
- continue
- elif command== "e":
- editItem()
- continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement