Skip to content

Instantly share code, notes, and snippets.

@mrroot5
Created May 8, 2019 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrroot5/f7ed6a97de7076e9c179fed064b0b59d to your computer and use it in GitHub Desktop.
Save mrroot5/f7ed6a97de7076e9c179fed064b0b59d to your computer and use it in GitHub Desktop.
Capitalize string
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