Advertisement
Guest User

Untitled

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