Sichanov

gg

Oct 3rd, 2021
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. gifts_planned = input()
  2. gifts_planned_list = gifts_planned.split()
  3. command = input()
  4. index_counter = 0
  5. for counter in range(len(gifts_planned_list)):
  6.     index_counter += 1
  7. while command != "No Money":
  8.     if 'OutOfStock' in command:
  9.         gift_to_replace = command.split()[1]
  10.         for replace in range(len(gifts_planned_list)):
  11.             if gifts_planned_list[replace] == gift_to_replace:
  12.                 gifts_planned_list[replace] = "None"
  13.     elif "Required" in command:
  14.         given_gift = command.split()[1]
  15.         value = int(command.split()[2])
  16.         if 0 <= value < index_counter:
  17.             gifts_planned_list[value] = given_gift
  18.     elif "JustInCase" in command:
  19.         command_list = command.split()
  20.         value = (command[-1])
  21.         command_sliced = command_list[1:2]
  22.         gifts_planned_list[-1] = "".join(command_sliced)
  23.  
  24.     command = input()
  25. gifts = [element for element in gifts_planned_list if element != "None"]
  26. print(" ".join(gifts))
  27.  
Advertisement
Add Comment
Please, Sign In to add comment