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 -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -