Don't use print() to debug your code.
Debugging with print statements is a messy and inelegant approach. It is confusing to map the output to its corresponding debug statement. Moreover, it requires extra manual formatting to comprehend the output.
The "icecream" library in Python is an excellent alternative to this. It makes debugging effortless and readable, with minimal code. Features include printing expressions, variable names, function names, line numbers, filenames, and many more.
P.S. The snippet only gives a brief demonstration. However, the actual functionalities are much more powerful and elegant as compared to debugging with print().
More about icecream here: https://github.com/gruns/icecream.
Thanks for reading Daily Dose of Data Science! Subscribe for free to learn something new and insightful about Python and Data Science every day. Also, get a Free Data Science PDF (250+ pages) with 200+ tips.