Advertisement
simeonshopov

Email validator

Mar 1st, 2020
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. #!/usr/local/bin/python3.7
  2. # -*- coding: utf-8 -*import
  3.  
  4. text = input()
  5.  
  6. while True:
  7.     command = input()
  8.     if command == 'Complete':
  9.         break
  10.     res = ''
  11.     if command == 'GetUsername':
  12.         if '@' in text:
  13.             res = text[:text.index('@')]
  14.         else:
  15.             res = f"The email {text} doesn't contain the @ symbol."
  16.     elif command == 'Encrypt':
  17.         res = ' '.join([str(ord(x)) for x in text])
  18.     else:
  19.         args = command.split()
  20.         cmd = args[0]
  21.         if cmd == 'Make' and len(args) > 1:
  22.             if args[1] == 'Upper':
  23.                 text = text.upper()
  24.                 res = text
  25.             elif args[1] == 'Lower':
  26.                 text = text.lower()
  27.                 res = text
  28.         elif cmd == 'GetDomain' and len(args) > 1:
  29.             count = int(args[1])
  30.             res = text[-count:]
  31.         elif cmd == 'Replace':
  32.             letter = args[1]
  33.             if letter in text:
  34.                 res = text.replace(letter, '-')
  35.     if res:
  36.         print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement