How to use pprint to print a dictionary on multiple lines in Python

1 Answer

0 votes
import pprint

dic = {'a':11, 'b':22, 'c':33, 'ww': {1:1, 2:2, 3:3}}

pprint.pprint(dic, width=1)



'''
run:

{'a': 11,
 'b': 22,
 'c': 33,
 'ww': {1: 1,
        2: 2,
        3: 3}}

'''

 



answered May 25, 2019 by avibootz

Related questions

1 answer 243 views
3 answers 409 views
2 answers 369 views
2 answers 266 views
1 answer 316 views
2 answers 328 views
...