Advertisement
pacho_the_python

Statistics

Mar 14th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. store = {}
  2. command = input()
  3.  
  4. while True:
  5.  
  6.     if command == "statistics":
  7.         break
  8.  
  9.     current_tack = command.split(": ")
  10.     food = current_tack[0]
  11.     quantity = int(current_tack[1])
  12.     if food in store.keys():
  13.         store[food] += quantity
  14.     else:
  15.         store[food] = quantity
  16.  
  17.     command = input()
  18.  
  19. print("Products in stock:")
  20.  
  21. for (key, value) in store.items():
  22.     print(f"- {key}: {value}")
  23.  
  24. all_keys = len(store.keys())
  25. total_values = sum(store.values())
  26.  
  27. print(f"Total Products: {all_keys}")
  28. print(f"Total Quantity: {total_values}")
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement