Advertisement
Adess0

1ss

Aug 15th, 2022
601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. username = input()
  2. command = input()
  3.  
  4. while command:
  5.     command = command.split()
  6.     if command[0] == "Letters":
  7.         if command[1] == "Lower":
  8.             username = username.lower()
  9.             print(username)
  10.         if command[1] == "Upper":
  11.             username = username.upper()
  12.             print(username)
  13.     elif command[0] == "Reverse":
  14.         start_index = int(command[1])
  15.         end_index = int(command[2])
  16.         substring_to_be_reversed = ''
  17.         if 0 <= start_index < len(username) and 0 <= end_index < len(username):
  18.             substring_to_be_reversed = username[start_index:end_index+1]
  19.             substring_to_be_reversed = substring_to_be_reversed[::-1]
  20.             print(substring_to_be_reversed)
  21.         else:
  22.             continue
  23.     elif command[0] == "Substring":
  24.         substr = command[1]
  25.         if substr in username:
  26.             username = username.replace(substr, '')
  27.             print(username)
  28.         else:
  29.             print(f"The username {username} doesn't contain {substr}.")
  30.  
  31.     elif command[0] == "Replace":
  32.         character = command[1]
  33.         username = username.replace(character, "-")
  34.         print(username)
  35.     elif command[0] == "IsValid":
  36.         char = command[1]
  37.         if char in username:
  38.             print("Valid")
  39.         else:
  40.             print(f"{char} must be contained in your username.")
  41.     elif command == "Registration":
  42.         break
  43.     command = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement