timpin

Tracey_shopping

Aug 17th, 2019
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. shopping =[]# The empty list MUST BE FIRST
  2. total_cost = [] # to store costs
  3.  
  4. how_many = input ("How many items of shopping do you have? ")
  5. how_many = int (how_many) #REMEMBER this is how you change the string variable
  6. # and CAST it into an integer.
  7.  
  8. for item_number in range (how_many):
  9. item = input ("What is the shopping item " + str (item_number) + "? ")
  10. cost = float(input ("How much does it cost" + str (item_number) + "£ "))
  11. shopping.append (item)
  12. total_cost.append (cost)
  13.  
  14. print(shopping) # You can omit these lines once you're happy that the code works
  15. print(total_cost) # although I would want to keep the shopping list
  16.  
  17. #for item_cost in range (cost_item):
  18. # item = input ("How much does it cost " + str(cost_item) + "? ")
  19. # shopping.append (cost)
  20.  
  21.  
  22.  
  23. #print ("Your shopping total is" )
Advertisement
Add Comment
Please, Sign In to add comment