Advertisement
MariyanGrigorov

Problem 1 - Registration-exam-mistake!!

Jun 17th, 2024 (edited)
651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | Software | 0 0
  1. user = input()
  2. len_user = len(user)
  3. command = input().split()
  4. new_string = user
  5.  
  6. while command[0] != "Registration":
  7.     if command[0] == 'Letters' and command[1] == 'Lower':
  8.         user = user.lower()
  9.         print(user)
  10.     elif command[0] == 'Letters' and command[1] == 'Upper':
  11.         user = user.upper()
  12.         print(user)
  13.     elif command[0] == 'Reverse':
  14.         start = int(command[1])
  15.         end = int(command[2])
  16.         if 0 <= start < len_user and 0 < end < len_user and start < end:
  17.             substring = user[start:end+1][::-1]
  18.             print(substring)
  19.         else:
  20.             print("Invalid indices. Start and end must be within the username length.")
  21.     elif command[0] == 'Substring':
  22.         if command[1] not in new_string:
  23.             print(f"The username {user} doesn't contain {command[1]}.")
  24.         else:
  25.             new_string = new_string.replace(command[1], '')
  26.             print(new_string)
  27.     elif command[0] == 'Replace':
  28.         new_string = user.replace(command[1], '-')
  29.         print(new_string)
  30.     elif command[0] == 'IsValid':
  31.         if command[1] in user:
  32.             print("Valid username.")
  33.         else:
  34.             print(f"{command[1]} must be contained in your username.")
  35.     command = input().split()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement