Tiny-Python-3.9-Notebook icon indicating copy to clipboard operation
Tiny-Python-3.9-Notebook copied to clipboard

Dictionary and looping

Open Proteusiq opened this issue 2 years ago • 0 comments

Would the following change the existing code be more efficient?

>>> for name in instruments.keys():
...     print('{} - {}'.format(name,
...           instruments[name]))

Or

>>> for name, instrument in instruments.items():
...     print('{} - {}'.format(name,
...           instrument))

Proteusiq avatar Feb 09 '23 19:02 Proteusiq