Str() vs repr() in Python

In Python, the built-in str() and repr() functions both produce a textual representation of an object. Output: The difference between str() and repr() is: The str() function returns a user-friendly description of an object. The repr() method returns a developer-friendly string representation of an object. In this guide, you learn: What are the functions str() …

Str() vs repr() in Python Read More »

Python Code

Comments in Python

Leaving code comments might sometimes help clarify your code. There are 3 unofficial comment types in Python. A “block comment”: An “inline comment”: A “multi-line” comment that misuses a docstring: Commenting Code in Python To add a comment in Python, use the hashtag operator # before starting to type the comment. Before digging into the …

Comments in Python Read More »

Python Pretty Print JSON

To pretty-print JSON in Python: Call the json.dumps() method on a JSON object. Specify the desired number of indentations for each row. For example: Where: json_obj is the JSON object you want to pretty-print. indent is the number of indentations, which is commonly 2 or 4. Here is an illustration of what pretty-printing does to …

Python Pretty Print JSON Read More »


📘 is an online learning platform founded and operated by me, Artturi Jalli. ✏️ At the beginning of 2021, I started writing technical articles on a popular platform I was quickly selected as one of the top writers on the platform. I received 300k+ reads in no time. 🖥️ I realized how big …

About Read More »