Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- command = input()
- names_dict = {}
- while not command == 'shopping time':
- action, key, value = command.split(" ")
- value = int(value)
- if key in names_dict:
- names_dict[key] += value
- else:
- names_dict[key] = value
- command = input()
- command_buy = input()
- while not command_buy == 'exam time':
- action, key, value = command_buy.split(" ")
- quantity = int(value)
- if key in names_dict:
- if quantity <= 0:
- print(f"{key} out of stock")
- elif quantity > names_dict[key]:
- quantity = 0
- else:
- names_dict[key] -= quantity
- else:
- print(f"{key} doesn't exist")
- command_buy = input()
- for key, value in names_dict.items():
- print(f"{key} -> {value}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement