Advertisement
George_Ivanov05

0.2

Jul 10th, 2021
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. biscuits_input = input().split(", ")
  2. my_command = input()
  3.  
  4. out = False
  5.  
  6. while not my_command == "No More Money":
  7.     command_data = my_command.split()
  8.     if command_data[0] == "OutOfStock":
  9.         biscuit = command_data[1]
  10.         for i in biscuits_input:
  11.             out = False
  12.             if biscuit in biscuits_input:
  13.                 biscuits_input.remove(biscuit)
  14.                 out = True
  15.     elif command_data[0] == "Required":
  16.         biscuit = command_data[1]
  17.         index = int(command_data[2])
  18.         if 0 <= index < len(biscuits_input):
  19.             biscuits_input.insert(index, biscuit)
  20.             if out == True:
  21.                 biscuits_input.remove(biscuits_input[index - 1])
  22.     elif command_data[0] == "Last":
  23.         biscuit = command_data[1]
  24.         biscuits_input.append(biscuit)
  25.  
  26.     my_command = input()
  27.  
  28. print(" ".join(biscuits_input))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement