Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- owned_cars = input().split(", ")
- number_of_items = int(input())
- while number_of_items:
- commands = input().split(", ")
- command = commands[0]
- if len(command) > 6:
- index = int(commands[1])
- if index in range(0, len(owned_cars)):
- owned_cars.remove(owned_cars[index])
- print("Card successfully sold")
- else:
- print("Index out of range")
- elif command == "Add":
- car = commands[1]
- if car in owned_cars:
- print("Card is already bought")
- else:
- print("Card successfully bought")
- owned_cars.append(car)
- elif command == "Remove":
- car = commands[1]
- if car in owned_cars:
- print("Card successfully sold")
- owned_cars.remove(car)
- else:
- print("Card not found")
- elif command == "Insert":
- index = int(commands[1])
- car = commands[2]
- if not (index in range(0, len(owned_cars))) and not (car in owned_cars):
- print("Index out of range")
- elif (index in range(0, len(owned_cars))) and not (car in owned_cars):
- owned_cars.insert(index, car)
- print("Card successfully bought")
- elif (index in range(0, len(owned_cars))) and (car in owned_cars):
- print("Card is already bought")
- number_of_items -= 1
- print(f"{', '.join(owned_cars)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement