Advertisement
dgodinov

easter_gifts

May 28th, 2023
1,063
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | Source Code | 0 0
  1. gifts_to_buy = input().split()
  2.  
  3. command = []
  4.  
  5. while True:
  6.     command = input()
  7.     if command == "No Money":
  8.         break
  9.     splitted_command = command.split()
  10.     if splitted_command[0] == "OutOfStock":
  11.         for i in range(len(gifts_to_buy)):
  12.             if gifts_to_buy[i] == splitted_command[1]:
  13.                 gifts_to_buy[i] = "None"
  14.     elif splitted_command[0] == "Required":
  15.         index_number = []
  16.         gift_to_change = []
  17.         index_number.append(splitted_command[2])
  18.         gift_to_change.append(splitted_command[1])
  19.         digit_index = [int(x) for x in index_number]
  20.         for digit_index in range(len(digit_index) + 1, len(splitted_command)):
  21.             gifts_to_buy[digit_index] = "".join(gift_to_change)
  22.     elif splitted_command[0] == "JustInCase":
  23.         gifts_to_buy.pop(-1)
  24.         gifts_to_buy.append(splitted_command[1])
  25.  
  26. while "None" in gifts_to_buy:
  27.     gifts_to_buy.remove("None")
  28. print(" ".join(gifts_to_buy))
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement