Answers for "how to traverser to a dictionary in python?"

39

python iterate through dictionary

a_dict = {'apple':'red', 'grass':'green', 'sky':'blue'}
for key in a_dict:
  print key # for the keys
  print a_dict[key] # for the values
Posted by: Guest on November-12-2019
1

traversing dictionary in python

#traversing dictionary function
d={1:'one',2:'two',3:'three',4:'four'}
print(d)
for i in d:
       print(i,d[i])
Posted by: Guest on December-22-2021

Code answers related to "how to traverser to a dictionary in python?"

Python Answers by Framework

Browse Popular Code Answers by Language