Print the keys and values of a dictionary

In this program, we will print the keys and values of a dictionary.

Steps to solve the program
  1. Take a Dictionary as input.
  2. Get the keys and values of the dictionary using items().
  3. Use for loop to iterate over keys and values of the Dictionary.
  4. Print the output.
				
					dict1 = {'name':'virat','sports':'cricket'}

for key,val in dict1.items():
    print(key,val)
				
			

Output :

				
					name virat
sports cricket
				
			

print the values of the keys of a dictionary

print the first 20 natural numbers using a while loop

Leave a Comment