Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- information = {}
- command = input()
- sold_quantity = 0
- while not command == 'Complete':
- command, quantity, food = command.split()
- if command == 'Receive':
- if food not in information and int(quantity) > 0:
- information[food] = int(quantity)
- elif int(quantity) > 0:
- information[food] += int(quantity)
- elif command == 'Sell':
- if food not in information:
- print(f'You do not have any {food}.')
- elif information[food] < int(quantity):
- sold_quantity += information[food]
- print(f"There aren't enough {food}. You sold the last {information[food]} of them.")
- information.pop(food)
- else:
- sold_quantity += int(quantity)
- information[food] -= int(quantity)
- print(f'You sold {quantity} {food}.')
- if information[food] == 0:
- information.pop(food)
- command = input()
- for k, v in sorted(information.items()):
- print(f'{k}: {v}')
- print(f'All sold: {sold_quantity} goods')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement