Yanam

Untitled

Oct 1st, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. gifts = list(map(str, input().split(' ')))
  2.  
  3. while True:
  4.     command = input()
  5.     if command == 'No Money':
  6.         break
  7.     command = command.split(' ')
  8.     if command[0] == 'OutOfStock':
  9.         for el in gifts:
  10.             if el == command[1]:
  11.                 gifts[gifts.index(el)] = None
  12.     elif command[0] == 'Required':
  13.         req = int(command[2])
  14.         if -len(gifts) <= req < len(gifts):
  15.             gifts[req] = command[1]
  16.     elif command[0] == 'JustInCase':
  17.         gifts[-1] = command[1]
  18. for el in gifts:
  19.     if el is None:
  20.         gifts.remove(el)
  21. print(*gifts)
Advertisement
Add Comment
Please, Sign In to add comment