Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- command = input()
- products = {}
- while not command == 'buy':
- split_command = command.split()
- product = split_command[0]
- price = float(split_command[1])
- quantity = int(split_command[2])
- if product not in products:
- products[product] = [price, quantity]
- else:
- if products[product][0] != price:
- products[product][0] = price
- products[product][1] += quantity
- command = input()
- print('\n'.join(f'{key} -> {value[0] * value[1]:.2f}' for key, value in products.items()))
Advertisement
Add Comment
Please, Sign In to add comment