python - Can you use enumerate for multiple objects? -


i'm wondering if have 2 (or maybe more) dictionaries defined in python keys , corresponding data, can access both elements enumerate statement?:

for i, key1, key2 in enumerate(dict1,dict2) ... "do something" 

thanks!

no, can this:

for i, (key1, key2) in enumerate(zip(dict1, dict2)):     #     pass 

but remember:

  • a dictionary's elements unordered, can't predict in order keys appear - might change when dictionaries grow.
  • if 1 dictionary has more elements other, of keys won't show in iteration. if both dictionaries have same size it'll work fine.

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -