Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def outofstock(gifts_list, command):
- gift = command[1]
- for i in range(len(gifts_list)):
- if gift == gifts_list[i]:
- gifts_list[i] = "None"
- return gifts_list
- def required(gifts_list, command):
- gift = command[1]
- index = int(command[2])
- if 0 <= index < len(gifts_list):
- gifts_list[index] = gift
- return gifts_list
- def justincase(gifts_list, command):
- gift = command[1]
- gifts_list[-1] = gift
- return gifts_list
- def final_print(gifts_list):
- for i in gifts_list:
- if i != "None":
- print(i, end=" ")
- gifts_list = input().split()
- while True:
- command = input().split()
- if command[0].startswith("No"):
- break
- if command[0] == "OutOfStock":
- gifts_list = outofstock(gifts_list, command)
- elif command[0] == "Required":
- gifts_list = required(gifts_list, command)
- elif command[0] == "JustInCase":
- gifts_list = justincase(gifts_list, command)
- final_print(gifts_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement