Last active
November 8, 2015 04:49
-
-
Save sidharthshah/c1398bad23c21f2dced2 to your computer and use it in GitHub Desktop.
Simple way to format name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from string import strip | |
def format_name(name): | |
#Step 1: Split by , | |
#Step 2: Remove any extrac white space in tokens using Map | |
#Step 3: Reverse List using ::-1 | |
#Step 4: Join with White Space | |
return " ".join(map(strip, name.split(","))[::-1]) | |
>>> format_name("Shah, Saheb") | |
'Saheb Shah' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment