GroZnik81

2ra_

Dec 17th, 2020 (edited)
19
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def outofstock(gifts_list,gift):
  2.     if gift in gifts_list:
  3.         for i in range (len(gifts_list)):
  4.             if gifts_list[i] == gift:
  5.                 gifts_list[i] = "None"
  6.     return gifts_list
  7.  
  8. def required(gifts_list,gift,index):
  9.     if 0<=index<len(gifts_list):
  10.         for i in range (len(gifts_list)):
  11.             if gifts_list[index] == gifts_list[i]:
  12.                 gifts_list[i] = gift
  13.     return gifts_list
  14.  
  15. def justincase(gifts_list,gift):
  16.     gifts_list[-1] = gift
  17.     return gifts_list
  18.  
  19. gifts = input().split()
  20.  
  21. data = input()
  22. while not data == "No Money":
  23.     command_data = data.split()
  24.     command = command_data[0]
  25.     if command == "OutOfStock":
  26.         gift = command_data[1]
  27.         gifts = outofstock(gifts,gift)
  28.     elif command == "Required":
  29.         gift = command_data[1]
  30.         index = int(command_data[2])
  31.         if  index <= (len(gifts)):
  32.             gift = command_data[1]
  33.             index = int(command_data[2])
  34.             gifts= required(gifts,gift,index)
  35.         else:
  36.             continue
  37.     elif command == "JustInCase":
  38.         gift = command_data[1]
  39.         gifts = justincase(gifts,gift)
  40.     data = input()
  41. for el in gifts:
  42.     if el == "None":
  43.         gifts.remove(el)
  44. print(" ".join(gifts))
  45.  
RAW Paste Data