Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gifts_to_buy = input().split()
- command = []
- while True:
- command = input()
- if command == "No Money":
- break
- splitted_command = command.split()
- if splitted_command[0] == "OutOfStock":
- for i in range(len(gifts_to_buy)):
- if gifts_to_buy[i] == splitted_command[1]:
- gifts_to_buy[i] = "None"
- elif splitted_command[0] == "Required":
- index_number = []
- gift_to_change = []
- index_number.append(splitted_command[2])
- gift_to_change.append(splitted_command[1])
- digit_index = [int(x) for x in index_number]
- for digit_index in range(len(digit_index) + 1, len(splitted_command)):
- gifts_to_buy[digit_index] = "".join(gift_to_change)
- elif splitted_command[0] == "JustInCase":
- gifts_to_buy.pop(-1)
- gifts_to_buy.append(splitted_command[1])
- while "None" in gifts_to_buy:
- gifts_to_buy.remove("None")
- print(" ".join(gifts_to_buy))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement