In this python dictionary program, we will access the dictionary key.
Steps to solve the program
- Take a dictionary as input.
- Use for loop with keys() function to access the keys of the dictionary.
- Print the output.
D1 = {"pepsi":50,"sprite":60,"slice":55}
for key in D1.keys():
print(key)
Output :
pepsi
sprite
slice