for loop - Python: iterating dictionaries with for -


suppose have 2 dictionaries

x = {'a': 5, 'b': 4}  y = {'a': 8, 'b': 3} 

and want print 'x' , 'y' values 'a' , 'b' mentioning 'x' , 'y' values a , b using loop. how can that? beginner please me syntax here.

it should like

a x:5 y:8  b x:4 y:3 

just loop through keys , print corresponding values:

for key in x.iterkeys():     print key     print 'x:%d' % x[key]     print 'y:%d' % y[key]     print 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

node.js - Express and Redis - If session exists for this user, don't allow access -

excel - I can't get the attachement of the email PHP -