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 171 views
3 answers 160 views
1 answer 148 views
3 answers 215 views
1 answer 113 views
1 answer 97 views
3 answers 160 views
...