Advertisement
bl00dt3ars

01. Password Reset

Aug 19th, 2021
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. string = input()
  2. command = input()
  3.  
  4. while not command == 'Done':
  5.     command = command.split()
  6.     if command[0] == 'TakeOdd':
  7.         string = ''.join([string[el] for el in range(len(string)) if el % 2 == 1])
  8.         print(string)
  9.     elif command[0] == 'Cut':
  10.         index = int(command[1])
  11.         length = int(command[2])
  12.         string = string[:index] + string[index+length:]
  13.         print(string)
  14.     elif command[0] == 'Substitute':
  15.         substring = command[1]
  16.         substitute = command[2]
  17.         if substring in string:
  18.             string = string.replace(substring, substitute)
  19.             print(string)
  20.         else:
  21.             print('Nothing to replace!')
  22.     command = input()
  23.  
  24. print(f'Your password is: {string}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement