Advertisement
viligen

password_reset

Nov 22nd, 2021
1,231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. new_password = input()
  2. while True:
  3.     command = input().split(" ")
  4.     if "Done" == command[0]:
  5.         break
  6.  
  7.     if "TakeOdd" == command[0]:
  8.         temp = ''
  9.         for i in range(1, len(new_password), 2):
  10.             temp += new_password[i]
  11.         new_password = temp
  12.         print(new_password)
  13.     elif "Cut" == command[0]:
  14.         index = int(command[1])
  15.         length = int(command[2])
  16.         if index >= 0:
  17.             cut_string = new_password[index:index+length]
  18.         else:
  19.             cut_string = new_password[index:index-length:-1]
  20.             cut_string = cut_string[-1::-1]
  21.         new_password = new_password.replace(cut_string, '', 1)
  22.         print(new_password)
  23.     elif "Substitute" == command[0]:
  24.         substring = command[1]
  25.         substitute = command[2]
  26.         if substring not in new_password:
  27.             print(f"Nothing to replace!")
  28.         else:
  29.             new_password = new_password.replace(substring, substitute)
  30.             print(new_password)
  31. print(f"Your password is: {new_password}")
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement