Advertisement
viligen

password_reset_2

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