Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- products = input().split("|")
- command = input()
- while not command == "Shop!":
- new_command = command.split("%")
- command_name = new_command[0]
- first_product = new_command[1]
- if command_name == "Important":
- if first_product in products:
- products.remove(first_product)
- products.insert(0, first_product)
- elif command_name == "Add":
- if first_product not in products:
- products.append(first_product)
- else:
- print("The product is already in the list.")
- elif command_name == "Swap":
- second_product = new_command[2]
- if first_product in products and second_product in products:
- index_one = products.index(first_product)
- index_two = products.index(second_product)
- products[index_one], products[index_two] = products[index_two], products[index_one]
- else:
- if first_product not in products:
- print(f"Product {first_product} missing!")
- else:
- print(f"Product {second_product} missing!")
- elif command_name == "Remove":
- if first_product in products:
- products.remove(first_product)
- else:
- print(f"Product {first_product} isn't in the list.")
- command = input()
- for i in range(len(products)):
- print(f'{i + 1}. {products[i]}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement