In this python dictionary program, we will iterate over a dictionary using a for loop.
Steps to solve the program
- Take a dictionary as input.
- Use for loop to iterate over keys of the dictionary.
- With the help of the keys access the values of the respective keys.
- Print the output.
D1 = {'food':'burger','type':'fast food'}
for val in D1:
print(val,D1[val])
Output :
food burger
type fast food