Function to Print a nicely formatted Dictionary or List?

Avi Gross avigross at verizon.net
Thu Jun 9 14:06:05 EDT 2022


Dave,

Despite your other programming knowledge, I suspect you think this is the forum where people come to be tutored. Try here:

https://mail.python.org/mailman/listinfo/tutor

Yes, there are plenty of pretty printers available and you can build your own function fairly easily. A module like pprint may have what you want in pprint.pprint()  but you can write a function for yourself that takes a  dictionary and loops through items and prints them one per line and, if you feel like it, also prints how many items there are and your own custom touches such as doing them alphabetically.
Consider using a search engine before posting. Throw in a few words like "python pretty print dictionary function" and refine that if it does not get you immediate results. It is free and easy and does not waste time for so many others who already know or don't care.
And consider reading a few books perhaps designed to teach python to people with some programming experience or taking a course on something like COURSERA as a part of your learning process and not depending on volunteers so much. Much of what you are asking is covered in fairly beginner and intermediate such books/courses.

I think I am now going to ignore messages from you for a while. Signal to noise ratio ...


-----Original Message-----
From: Dave <dave at looktowindward.com>
To: python-list at python.org
Sent: Thu, Jun 9, 2022 6:43 am
Subject: Function to Print a nicely formatted Dictionary or List?

Hi,

Before I write my own I wondering if anyone knows of a function that will print a nicely formatted dictionary?

By nicely formatted I mean not all on one line!

Cheers
Dave

-- 
https://mail.python.org/mailman/listinfo/python-list


More information about the Python-list mailing list