bl00dt3ars

Untitled

Aug 20th, 2021
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. word = [el for el in input()]
  2.  
  3. while True:
  4.     command = input()
  5.     if 'Move' in command:
  6.         command = command.split()
  7.         index = int(command[1])
  8.         if 0 <= index < len(word):
  9.             word.append(word.pop(index))
  10.     elif 'Insert' in command:
  11.         command = command.split()
  12.         index = int(command[2])
  13.         word.insert(index, ' ')
  14.     elif 'Reverse' in command:
  15.         command = command.split()
  16.         substring = command[1]
  17.         if substring in ''.join(word):
  18.             word = ''.join(word)
  19.             word = word.replace(substring, '', 1) + ''.join(reversed(substring))
  20.             word = [el for el in word]
  21.     elif 'Exchange' in command and 'Tiles' in command:
  22.         command = command.split()
  23.         new_letter = command[2]
  24.         for i in range(len(new_letter)):
  25.             if not word[i] == ' ':
  26.                 word[i] = new_letter[i]
  27.             else:
  28.                 word.insert(i, new_letter[i])
  29.         print(' '.join(word))
  30.         break
  31.     elif command == 'Pass':
  32.         print(' '.join(word))
  33.         break
  34.     elif command == 'Play':
  35.         word = ''.join(word).split()
  36.         print(f'You are playing with the word {word[0]}.')
  37.         break
Advertisement
Add Comment
Please, Sign In to add comment