Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cards = input().split(', ')
- number = int(input())
- for i in range(1, number + 1):
- command_data = input().split(', ')
- command = command_data[0]
- if command == 'Add':
- card_name = command_data[1]
- if card_name not in cards:
- cards.append(card_name)
- print('Card successfully added')
- else:
- print('Card is already in the deck')
- elif command == 'Remove':
- card_to_remove = command_data[1]
- if card_to_remove in cards:
- cards.remove(card_to_remove)
- print('Card successfully removed')
- else:
- print('Card not found')
- elif command == 'Remove At':
- card_idx = int(command_data[1])
- if 0 <= card_idx < len(cards):
- cards.pop(card_idx)
- print('Card successfully removed')
- else:
- print('Index out of range')
- elif command == 'Insert':
- insert_idx = int(command_data[1])
- insert_card_name = command_data[2]
- if insert_card_name in cards:
- print('Card is already added')
- elif insert_idx < 0 or insert_idx >= len(cards):
- print('Index out of range')
- else:
- cards.insert(insert_idx, insert_card_name)
- print('Card successfully added')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement