Advertisement
lubattillah

shopping cart

May 16th, 2019
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. """
  2. Shopping Program that
  3. Ask how many items of shopping are needed.
  4. Collect the items and store them in a list.
  5. Loop through the shopping list and display them.
  6. Show a total at the end so the user can see how many have been added.
  7. """
  8. shopping=[]
  9. items=int(input("How many items do you need? "))
  10. for item_number in range(items):
  11. item=input("What is item number "+str(item_number)+"? ")
  12. item_number+=1
  13. shopping.append(item)
  14.  
  15. if item_number==1:
  16. print("You have added",item_number,"item in your cart namely",shopping[0])
  17.  
  18. else:
  19. print("You have added",item_number,"items in your cart, here is a list:")
  20. for element in shopping:
  21. print(element)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement