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 260 views
3 answers 329 views
1 answer 249 views
3 answers 420 views
1 answer 218 views
1 answer 185 views
3 answers 330 views
...