Advertisement
bl00dt3ars

Untitled

Aug 20th, 2021
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.73 KB | None | 0 0
  1. email = input()
  2. while True:
  3.     command = input()
  4.     if command == "Valid":
  5.         break
  6.     data = command.split()
  7.     action = data[0]
  8.     if action == "Upper":
  9.         index = int(data[1])
  10.         email = email[:index] + email[index].upper() + email[index + 1:]
  11.         print(email)
  12.     elif action == "Lower":
  13.         index = int(data[1])
  14.         email = email[:index] + email[index].lower() + email[index + 1:]
  15.         print(email)
  16.     elif action == "Insert":
  17.         index = int(data[1])
  18.         char = data[2]
  19.         email = email[:index] + char + email[index:]
  20.         print(email)
  21.     elif action == "Change":
  22.         char = data[1]
  23.         value = int(data[2])
  24.         if char in email:
  25.             new = ord(char) + value
  26.             email = email.replace(char, chr(new))
  27.         print(email)
  28.     elif action == "Validation":
  29.         upper_count = 0
  30.         lower_count = 0
  31.         digit_count = 0
  32.         others = 0
  33.         for a in email:
  34.             if not a.isdigit() and not a.isalpha() and not a == "@":
  35.                 others += 1
  36.             elif a.isupper():
  37.                 upper_count += 1
  38.             elif a.islower():
  39.                 lower_count += 1
  40.             elif a.isdigit():
  41.                 digit_count += 1
  42.         if len(email) < 6:
  43.             print(f"Email must be at least 6 characters long!")
  44.         if others > 0:
  45.             print("Email must consist only of letters, digits and @!")
  46.         if upper_count == 0:
  47.             print("Email must consist at least one uppercase letter!")
  48.         if lower_count == 0:
  49.             print("Email must consist at least one lowercase letter!")
  50.         if digit_count == 0:
  51.             print("Email must consist at least one digit!")
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement