How to create, initialize and print a dictionary in Python

2 Answers

0 votes
dic = dict()

dic['a'] = 'python'
dic['b'] = 'java'
dic['c'] = 'php'

for keys, values in dic.items():
    print(keys)
    print(values)


'''
run:

a
python
c
php
b
java

'''

 



answered Oct 24, 2017 by avibootz
0 votes
dic = {'a': 'python', 'b': 'java', 'c': 'php'}

for keys, values in dic.items():
    print(keys)
    print(values)


'''
run:

a
python
b
java
c
php

'''

 



answered Oct 24, 2017 by avibootz

Related questions

1 answer 112 views
3 answers 113 views
2 answers 193 views
3 answers 263 views
1 answer 132 views
...