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 266 views
3 answers 335 views
1 answer 256 views
3 answers 425 views
1 answer 232 views
1 answer 192 views
3 answers 338 views
...