Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def outofstock(gifts_list, gift):
- for i in range(len(gifts_list)):
- if gift == gifts_list[i]:
- gifts_list[i] = "None"
- return gifts_list
- def required(gifts_list, gift, index):
- if 0 <= index < len(gifts_list):
- gifts_list[index] = gift
- return gifts_list
- def justincase(gifts_list, gift):
- 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
- gift = command[1]
- if command[0] == "OutOfStock":
- gifts_list = outofstock(gifts_list, gift)
- elif command[0] == "Required":
- index = int(command[2])
- gifts_list = required(gifts_list, gift, index)
- elif command[0] == "JustInCase":
- gifts_list = justincase(gifts_list, gift)
- final_print(gifts_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement