Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cards = input().split(':')
- result = []
- command = input()
- while command != 'Ready':
- tokens = command.split()
- if tokens[0] == 'Add':
- card = tokens[1]
- if card not in cards:
- print("Card not found.")
- else:
- result.append(card)
- elif tokens[0] == 'Insert':
- index = int(tokens[2])
- if not 0 <= index < len(cards) or tokens[1] not in cards:
- print("Error!")
- else:
- result.insert(index, tokens[1])
- elif tokens[0] == 'Remove':
- if tokens[1] not in result:
- print("Card not found.")
- else:
- result.remove(tokens[1])
- elif tokens[0] == 'Swap':
- x = tokens[1]
- y = tokens[2]
- index_1 = result.index(x)
- index_2 = result.index(y)
- result[index_1], result[index_2] = result[index_2], result[index_1]
- elif tokens[0] == 'Shuffle':
- result.reverse()
- command = input()
- print(' '.join(result))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement