Advertisement
simeonshopov

Valid Usernames

Feb 10th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. words = input().split(', ')
  2. ALLOWED = (ord('-'), ord('_'))
  3.  
  4. def sanitize(w: str):
  5.     found = False
  6.     if 3 <= len(w) <= 16:
  7.         for i in w:
  8.             i= ord(i.lower())
  9.             if i in range(97, 123) or i in ALLOWED or i in range(48, 58):
  10.                 found = True
  11.             else:
  12.                 found = False
  13.                 break
  14.         if found:
  15.             return w
  16.  
  17. for word in words:
  18.     if sanitize(word):
  19.         print(word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement