Advertisement
Guest User

easter_gifts

a guest
Feb 17th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. gifts = input().split()
  2.  
  3. command = input()
  4.  
  5. while command != 'No Money':
  6.     arg = command.split()
  7.    
  8.     command = arg[0]
  9.     current_gift = arg[1]
  10.  
  11.     if command == 'OutOfStock':
  12.         gift = current_gift
  13.         for item in range(len(gifts)):
  14.             if gifts[item] == gift:
  15.                 gifts[item] = 'None'
  16.     elif command == 'Required':
  17.         idx = int(arg[2])
  18.         if 0 <= idx <= len(gifts):
  19.             gifts[idx] = current_gift
  20.     elif command == 'JustInCase':
  21.         gifts[-1] = current_gift
  22.  
  23.     command = input()
  24.  
  25. result = []
  26.  
  27. for gift in gifts:
  28.     if gift is not 'None':
  29.         result.append(gift)
  30.  
  31. print(' '.join(result))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement