Skip to content

Instantly share code, notes, and snippets.

@sojohnnysaid
Last active January 19, 2021 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sojohnnysaid/6ea1adeff0cf8299768fda722f86ac21 to your computer and use it in GitHub Desktop.
Save sojohnnysaid/6ea1adeff0cf8299768fda722f86ac21 to your computer and use it in GitHub Desktop.
Python initial generator using regular expressions
#Extract users initials
from cs50 import get_string
import re
def main():
userName = get_string("enter full name: ")
print(getInitials(userName))
def getInitials(fullName):
list = re.findall(r'(^[a-zA-Z]|(?<=\s)[a-zA-Z])', fullName)
return '.'.join([i.upper() for i in list])
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment