In this program, we will print the keys and values of a dictionary.
Steps to solve the program
- Take a Dictionary as input.
- Get the keys and values of the dictionary using items().
- Use for loop to iterate over keys and values of the Dictionary.
- Print the output.
dict1 = {'name':'virat','sports':'cricket'}
for key,val in dict1.items():
print(key,val)
Output :
name virat
sports cricket