Program to print the keys of a dictionary

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

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

for keys in dict1.keys():
    print(keys)
				
			

Output :

				
					name
sports
				
			

create an empty list and add odd numbers from 1-10

print the values of the keys of a dictionary

Leave a Comment