Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def outofstock(gifts_list,gift):
- if gift in gifts_list:
- for i in range (len(gifts_list)):
- if gifts_list[i] == gift:
- gifts_list[i] = "None"
- return gifts_list
- def required(gifts_list,gift,index):
- if 0<=index<len(gifts_list):
- for i in range (len(gifts_list)):
- if gifts_list[index] == gifts_list[i]:
- gifts_list[i] = gift
- return gifts_list
- def justincase(gifts_list,gift):
- gifts_list[-1] = gift
- return gifts_list
- gifts = input().split()
- data = input()
- while not data == "No Money":
- command_data = data.split()
- command = command_data[0]
- if command == "OutOfStock":
- gift = command_data[1]
- gifts = outofstock(gifts,gift)
- elif command == "Required":
- gift = command_data[1]
- index = int(command_data[2])
- if index <= (len(gifts)):
- gift = command_data[1]
- index = int(command_data[2])
- gifts= required(gifts,gift,index)
- else:
- continue
- elif command == "JustInCase":
- gift = command_data[1]
- gifts = justincase(gifts,gift)
- data = input()
- for el in gifts:
- if el == "None":
- gifts.remove(el)
- print(" ".join(gifts))
Add Comment
Please, Sign In to add comment