Advertisement
simeonshopov

Easter Gifts

Jan 20th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. #!/usr/local/bin/python3.7
  2. # -*- coding: utf-8 -*import
  3.  
  4. gifts = input().split()
  5. command = input()
  6.  
  7. while command != 'No Money':
  8.     command = command.split()
  9.     if 'OutOfStock' in command:
  10.         for word in gifts:
  11.             if word in command:
  12.                 command = word
  13.                 gifts = [x.replace(command, str(None)) for x in gifts]
  14.                 break
  15.     if 'Required' in command:
  16.         gift = command[1]
  17.         place = int(command[2])
  18.         if len(gifts) > place >= 0:
  19.             gifts[place] = gift
  20.     if 'JustInCase' in command:
  21.         gift = command[1]
  22.         gifts.remove(gifts[-1])
  23.         gifts.append(gift)
  24.     command = input()
  25. else:
  26.     gifts = [x for x in gifts if x != str(None)]
  27.     s = ' '
  28.     print(s.join(gifts))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement