Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cards_owned = input().split(", ")
- n = int(input())
- for i in range(n):
- command = input().split(", ")
- if command[0] == "Add":
- name = command[1]
- if name in cards_owned:
- print(f"Card is already bought")
- else:
- print(f"Card successfully bought")
- cards_owned.append(name)
- if command[0] == "Remove":
- name = command[1]
- if name in cards_owned:
- print("Card successfully sold")
- cards_owned.remove(name)
- else:
- print("Card not found")
- if command[0] == "Remove At":
- if int(command[1]) < len(cards_owned):
- del cards_owned[int(command[1])]
- print("Card successfully sold")
- else:
- print("Index out of range")
- if command[0] == "Insert":
- name = command[2]
- if int(command[1]) >= len(cards_owned):
- print("Index out of range")
- else:
- if command[2] not in cards_owned:
- cards_owned.insert(int(command[1]), name)
- print("Card successfully bought")
- else:
- print("Card is already bought")
- result_string = ", ".join(cards_owned)
- print(result_string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement