DiYane

Easter gifts

Jul 31st, 2023
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. gifts = input().split(' ')
  2.  
  3. command = input().split(' ')
  4. while command[0] != 'No' and command[1] != 'Money':
  5.     index = 0
  6.     if command[0] == 'OutOfStock':
  7.         gift = command[1]
  8.         gifts = list(map(lambda lst: lst.replace(gift, "None"), gifts))
  9.  
  10.     elif command[0] == 'Required':
  11.         index = int(command[2])
  12.         if 0 < index < len(gifts):
  13.             gifts[index] = command[1]
  14.  
  15.     elif command[0] == 'JustInCase':
  16.         gifts[-1] = command[1]
  17.  
  18.     command = input().split(' ')
  19.  
  20. while 'None' in gifts:
  21.     gifts.remove('None')
  22.  
  23. for i in gifts:
  24.     print(i, end=' ')
Tags: python
Add Comment
Please, Sign In to add comment