Skip to content

Home

Decapitalize string

Decapitalizes the first letter of a string.

def decapitalize(s, upper_rest = False):
  return ''.join([s[:1].lower(), (s[1:].upper() if upper_rest else s[1:])])

decapitalize('FooBar') # 'fooBar'
decapitalize('FooBar', True) # 'fOOBAR'

More like this

Start typing a keyphrase to see matching snippets.