Guest User

Untitled

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