Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- groceries = input().split("!")
- while True:
- command_str = input()
- if "Go Shopping!" in command_str:
- break
- command = command_str.split()
- if "Urgent" in command and command[1] not in groceries:
- item = command[1]
- groceries.insert(0, item)
- elif "Unnecessary" in command and command[1] in groceries:
- item = command[1]
- groceries.remove(item)
- elif "Correct" in command and command[1] in groceries:
- old_item = command[1]
- new_item = command[2]
- index_old = groceries.index(old_item)
- groceries[index_old] = new_item
- elif "Rearrange" in command and command[1] in groceries:
- item = command[1]
- groceries.remove(item)
- groceries.append(item)
- print(", ".join(groceries))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement