Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Created May 26, 2020 00:26
Show Gist options
  • Save hsleonis/1546ddbc1c65dc7a08a82108a2d0cb02 to your computer and use it in GitHub Desktop.
Save hsleonis/1546ddbc1c65dc7a08a82108a2d0cb02 to your computer and use it in GitHub Desktop.
Decapitalizes the first letter of a string.
def decapitalize(s, upper_rest=False):
  return s[:1].lower() + (s[1:].upper() if upper_rest else s[1:])
decapitalize('FooBar') # 'fooBar'
decapitalize('FooBar', True) # 'fOOBAR'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment