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 258 views
3 answers 325 views
1 answer 248 views
3 answers 419 views
1 answer 214 views
1 answer 183 views
3 answers 328 views
...