I often confused about what I was printing when I debug in Python.
Example:
str1 = "Apple"
str2 = "Orange"
print(str1)
print(str2)
The output would be:
Apple
Orange
It is not easy to tell what variable I am printing. Well, it is in the above simple example but not in a real program where you would use many variables. I could manually write the name of each variable inside print() but it is not efficient.
I wondered if there is a better way in this situation and bumped into Icecream, a useful Python library for debugging.
Install command:
pip install icecream
So let's use it in the above example:
from icecream import ic
str1 = "Apple"
str2 = "Orange"
ic(str1)
ic(str2)
Output:
ic| str1: 'Apple'
ic| str2: 'Orange'
Icecream prints a variable name along with its value. This made my Python life much easier. Use Icecream and cut your time in debugging!