Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- word = [el for el in input()]
- while True:
- command = input()
- if 'Move' in command:
- command = command.split()
- index = int(command[1])
- if 0 <= index < len(word):
- word.append(word.pop(index))
- elif 'Insert' in command:
- command = command.split()
- index = int(command[2])
- word.insert(index, ' ')
- elif 'Reverse' in command:
- command = command.split()
- substring = command[1]
- if substring in ''.join(word):
- word = ''.join(word)
- word = word.replace(substring, '', 1) + ''.join(reversed(substring))
- word = [el for el in word]
- elif 'Exchange' in command and 'Tiles' in command:
- command = command.split()
- new_letter = command[2]
- for i in range(len(new_letter)):
- if not word[i] == ' ':
- word[i] = new_letter[i]
- else:
- word.insert(i, new_letter[i])
- print(' '.join(word))
- break
- elif command == 'Pass':
- print(' '.join(word))
- break
- elif command == 'Play':
- word = ''.join(word).split()
- print(f'You are playing with the word {word[0]}.')
- break
Advertisement
Add Comment
Please, Sign In to add comment