Skip to content

Instantly share code, notes, and snippets.

@schuettc
Last active May 18, 2022 13:58
Show Gist options
  • Select an option

  • Save schuettc/3875da7458e3573646599e70b7b17a61 to your computer and use it in GitHub Desktop.

Select an option

Save schuettc/3875da7458e3573646599e70b7b17a61 to your computer and use it in GitHub Desktop.
Recursively Capitalize Keys - Python
def capitalize_keys(d):
for k, v in d.copy().items():
if isinstance(v, dict):
d.pop(k)
d[f"{k[0].upper() +k[1:]}"] = v
capitalize_keys(v)
else:
d.pop(k)
d[f"{k[0].upper() +k[1:]}"] = v
return d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment