Skip to content

Instantly share code, notes, and snippets.

View Beenhakker's full-sized avatar

Bas Beenhakker Beenhakker

  • Amsterdam, the Netherlands
  • 16:40 (UTC +01:00)
View GitHub Profile
@PatrikHlobil
PatrikHlobil / nested_iterator.py
Last active February 9, 2024 23:29
Get all keys or values of a nested dictionary or list in Python
def iterate_all(iterable, returned="key"):
"""Returns an iterator that returns all keys or values
of a (nested) iterable.
Arguments:
- iterable: <list> or <dictionary>
- returned: <string> "key" or "value"
Returns: