GeorgiLukanov87

gift list

Jun 1st, 2022 (edited)
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. gifts_list = input().split(" ")
  2. command = input()
  3.  
  4. while not command == 'No Money':
  5.     if 'OutOfStock' in command:
  6.         command, gift = command.split(" ")
  7.         for current_gift in range(len(gifts_list)):
  8.             if gifts_list[current_gift] == gift:
  9.                 gifts_list[current_gift] = 'None'
  10.     elif 'Required' in command:
  11.         command, gift, index = command.split(" ")
  12.         index = int(index)
  13.         if 0 < index < len(gifts_list):
  14.             gifts_list[index] = gift
  15.     elif 'JustInCase' in command:
  16.         command, gift = command.split(" ")
  17.         gifts_list[-1] = gift
  18.     command = input()
  19.  
  20. for gifts in range(len(gifts_list)):
  21.     if 'None' in gifts_list:
  22.         gifts_list.remove('None')
  23. print(' '.join(gifts_list))
Add Comment
Please, Sign In to add comment