Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- products = input().split('!')
- command = input()
- while not command == 'Go Shopping!':
- command = command.split()
- if command[0] == 'Urgent':
- item = command[1]
- if item not in products:
- products.insert(0, item)
- elif command[0] == 'Unnecessary':
- item = command[1]
- if item in products:
- products.remove(item)
- elif command[0] == 'Correct':
- old_item = command[1]
- new_item = command[2]
- new_products = []
- if old_item in products:
- for word in products:
- new_products.append(word)
- if word == old_item:
- result = word.replace(old_item, new_item)
- new_products.append(result)
- new_products.remove(old_item)
- products = new_products
- elif command[0] == 'Rearrange':
- item = command[1]
- if item in products:
- products.remove(item)
- products.append(item)
- command = input()
- print(', '.join(products))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement