Advertisement
LHerr

shopping cost

Feb 25th, 2020
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #Ask how many items of shopping are needed
  2. shopping = []
  3. how_many = input ("How many items of shopping do you have?")
  4. how_many = int(how_many)
  5. total = 0
  6. #Collect items and store in a list/ loop/ and print items
  7. for item_number in range(how_many):
  8. item = input("what is the item number" + str(item_number) + "?")
  9. shopping.append(item)
  10. print (shopping)
  11.  
  12. print ("Now lets calculate how much it will cost you")
  13. total_cost = 0
  14. for item in shopping:
  15. item_cost=input("how much is the item " + item)
  16. total_cost=total_cost+float(item_cost)
  17.  
  18. print("the total cost of your shopping is $" + str(total_cost))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement