Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dictionary_price = {}
- dictionary_quantity = {}
- while True:
- line = input()
- if line == "buy":
- break
- line_split = line.split()
- product = line_split[0]
- price = float(line_split[1])
- quantity = int(line_split[2])
- if product not in dictionary_price: # Ако продуктът НЕ Е в първия или във втория речник!!!
- dictionary_price[product] = price # Добавяме единичната цена към речника за цените
- dictionary_quantity[product] = quantity # Добавяме количеството къ, речника за количеството
- else:
- dictionary_price[product] = price # Обновява се цената
- dictionary_quantity[product] += quantity
- for product in dictionary_price:
- price = dictionary_price[product]
- quantity = dictionary_quantity[product]
- total_price = price * quantity
- print(f"{product} -> {total_price:.2f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement