Advertisement
Guest User

Untitled

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