Dictionary for loop : For « Language Basics « Python






Dictionary for loop

Dictionary for loop
dict = {'x': 1, 'y': 2, 'z': 3}
for key in dict:
    print key, 'corresponds to', dict[key]


           
       








Related examples in the same category

1.For loop demoFor loop demo
2.for with else for with else
3.Nested if demoNested if demo
4.Calculating compound interest.Calculating compound interest.