1a_dict = {'color': 'blue', 'fruit': 'apple', 'pet': 'dog'}
2for key, value in a_dict.items():
3 print(key, '->', value)
1a_dict = {'apple':'red', 'grass':'green', 'sky':'blue'}
2for key in a_dict:
3 print key # for the keys
4 print a_dict[key] # for the values
1#iterate the dict by keys
2for key in a_dict:
3 print(key)
4#iterate the dict by items - (key,value)
5for item in a_dict.items():
6 print(item)
7#iterate the dict by values
8for value in a_dict.values():
9 print(value)
1d = {'x': 1, 'y': 2, 'z': 3}
2for key in d:
3 print key, 'corresponds to', d[key]
1{% for key, value in data.items %}
2 <tr>
3 <td> Key: {{ key }} </td>
4 <td> Value: {{ value }} </td>
5 </tr>
6{% endfor %}