Created
May 8, 2019 09:21
-
-
Save mrroot5/f7ed6a97de7076e9c179fed064b0b59d to your computer and use it in GitHub Desktop.
Capitalize string
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
def capitalize(string, lower_rest=True): | |
return string[:1].upper() + (string[1:].lower() if lower_rest else string[1:]) | |
capitalize('fooBar') # 'Foobar' | |
capitalize('fooBar', False) # 'FooBar' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment