Lesser-known Feature of f-strings in Python
While debugging, one often explicitly prints the name of the variable with its value to enhance code inspection.
Although there's nothing wrong with this approach, it makes your print statements messy and lengthy.
f-strings in Python offer an elegant solution for this.
To print the name of the variable, you can add an equals sign (=) in the curly braces after the variable. This will print the name of the variable along with its value but it is concise and clean.
I like to explore, experiment and write about data science concepts and tools. You could connect with me on LinkedIn.