Advertisement
PowerCell46

Easter gifts Python

Dec 26th, 2022
1,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. names_of_the_gifts = str(input())
  2. names_of_the_gifts = names_of_the_gifts.split()
  3.  
  4. while True:
  5.     current_command = str(input())
  6.     if current_command == "No Money":
  7.         break
  8.     current_command = current_command.split()
  9.     current_command_real = current_command.pop(0)
  10.  
  11.     if current_command_real == "OutOfStock":
  12.         gift_name = current_command.pop(0)
  13.         while names_of_the_gifts.count(gift_name) > 0:
  14.             searched_index = names_of_the_gifts.index(gift_name)
  15.             names_of_the_gifts[searched_index] = "None"
  16.  
  17.     elif current_command_real == "Required":
  18.         gift_name1 = current_command.pop(0)
  19.         index_1 = int(current_command.pop(0))
  20.         if index_1 >= 0 and index_1 < len(names_of_the_gifts):
  21.             names_of_the_gifts[index_1] = gift_name1
  22.  
  23.     elif current_command_real == "JustInCase":
  24.         gift_name2 = current_command.pop(0)
  25.         names_of_the_gifts.pop(len(names_of_the_gifts) - 1)
  26.         names_of_the_gifts.append(gift_name2)
  27.  
  28. while names_of_the_gifts.count("None") > 0:
  29.     names_of_the_gifts.remove("None")
  30.  
  31. print(" ".join(names_of_the_gifts))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement