How to use 'python for each key in dict' in Python

Every line of 'python for each key in dict' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
464def dict_iter(dct):
465 for k,v in dct.items():
466 if isinstance(v, dict):
467 for kk,vv in dict_iter(v):
468 yield (kk, vv)
469 else:
470 yield (k, v)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code


Related snippets