glossary = { 'docstring': 'it is a short form of documentation string.', 'title': 'it is form of just heading.'}
Print('glossary')
CodePudding user response:
Use the pprint
library as @don't talk just code said.
It makes list, dictionary more readable
import pprint
glossary = { 'docstring': 'it is a short form of documentation string.', 'title': 'it is form of just heading.'}
pprint.pprint(glossary)
Output
{'docstring': 'it is a short form of documentation string.',
'title': 'it is form of just heading.'}
You could use str.replace
if you do not want to use a library.
glossary = { 'docstring': 'it is a short form of documentation string.', 'title': 'it is form of just heading.'}
print( str(glossary).replace(",", ",\n") )
This makes the dictionary a string, and replace every comma ,
to a comma with a new line ,\n
.
This probably has a lot of limitation