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
Post a Comment