How to iterate over the keys of a dictionary in Python

2 Answers

0 votes
dic = {"aa": "java", "bb": "c++", "cc": "python"}

for key in dic:
    print(key)


'''
run:
 
aa
bb
cc
 
'''

 



answered Dec 6, 2017 by avibootz
0 votes
dic = {"aa": "java", "bb": "c++", "cc": "python"}

for key in dic.keys():
    print(key)


'''
run:
 
aa
bb
cc
 
'''

 



answered Dec 6, 2017 by avibootz

Related questions

1 answer 185 views
3 answers 185 views
1 answer 164 views
3 answers 248 views
1 answer 127 views
1 answer 114 views
3 answers 187 views
...