Advertisement
go6odn28

easter_gift....

Apr 10th, 2024
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. def outofstock(gifts_list, command):
  2.     gift = command[1]
  3.     for i in range(len(gifts_list)):
  4.         if gift == gifts_list[i]:
  5.             gifts_list[i] = "None"
  6.     return gifts_list
  7.  
  8.  
  9. def required(gifts_list, command):
  10.     gift = command[1]
  11.     index = int(command[2])
  12.     if 0 <= index < len(gifts_list):
  13.         gifts_list[index] = gift
  14.     return gifts_list
  15.  
  16.  
  17. def justincase(gifts_list, command):
  18.     gift = command[1]
  19.     gifts_list[-1] = gift
  20.     return gifts_list
  21.  
  22.  
  23. def final_print(gifts_list):
  24.     for i in gifts_list:
  25.         if i != "None":
  26.             print(i, end=" ")
  27.  
  28.  
  29. gifts_list = input().split()
  30. while True:
  31.     command = input().split()
  32.     if command[0].startswith("No"):
  33.         break
  34.     if command[0] == "OutOfStock":
  35.         gifts_list = outofstock(gifts_list, command)
  36.     elif command[0] == "Required":
  37.         gifts_list = required(gifts_list, command)
  38.     elif command[0] == "JustInCase":
  39.         gifts_list = justincase(gifts_list, command)
  40. final_print(gifts_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement