Advertisement
Fati0345

7. Easter Gifts

May 28th, 2023 (edited)
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1.  
  2. #7 Easter Gifts
  3.  
  4.  
  5. input_gifts = input().split(" ")
  6.  
  7. while True:
  8.     command = input()
  9.     if command == "No Money":
  10.         break
  11.     else:
  12.         current_command = command.split(" ")
  13.         if current_command[0] == "OutOfStock":
  14.             for current_gift in input_gifts:
  15.                 if current_command[1] == current_gift:
  16.                     index_gift = input_gifts.index(current_gift)
  17.                     input_gifts[index_gift] = "None"
  18.         elif current_command[0] == "Required":
  19.             for index in range(len(input_gifts)):
  20.                 if int(current_command[2]) == index:
  21.                     input_gifts[index] = current_command[1]
  22.         elif current_command[0] == "JustInCase":
  23.             index_last_gift = len(input_gifts) - 1
  24.             input_gifts[index_last_gift] = current_command[1]
  25.  
  26. list_of_gifts = []
  27. for gift in input_gifts:
  28.     if gift != "None":
  29.         list_of_gifts.append(gift)
  30.  
  31. print(" ".join(list_of_gifts))
  32.  
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement