Created
November 7, 2025 17:13
-
-
Save lucasbracher/41154b9027e53abc9104ff949cd9bc80 to your computer and use it in GitHub Desktop.
empty_dict.py
This file contains hidden or 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
| # Get a dictionary and empty it, leaving just the structure: | |
| def empty_dict(d): | |
| if isinstance(d, dict): | |
| return {k: empty_dict(v) for k, v in d.items()} | |
| elif isinstance(d, list): | |
| return [empty_dict(d[0])] if d else [] | |
| else: | |
| return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment