Advertisement
bl00dt3ars

07. Easter Gifts

Jun 2nd, 2021
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. gifts = input().split()
  2. command = input()
  3.  
  4. while not command == "No Money":
  5.     splited_command = command.split()
  6.     if splited_command[0] == "OutOfStock":
  7.         gifts = [item if item != splited_command[1] else "None" for item in gifts]
  8.     elif splited_command[0] == "Required":
  9.         value = splited_command[1]
  10.         index = int(splited_command[2])
  11.         if 0 <= index < len(gifts):
  12.             gifts[index] = value
  13.     elif splited_command[0] == "JustInCase":
  14.         value = splited_command[1]
  15.         gifts[-1] = value
  16.        
  17.     command = input()
  18.  
  19. gifts = [item for item in gifts if not item == "None"]    
  20. print(" ".join(gifts))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement