My Coding >
Programming language >
Python >
Python FAQ >
Python: f-string for printing variables
Python: f-string for printing variablesF-string in Python makes the formation of the test string from a few variables much simpler and I would like to encourage you to use f-string more often. For example, if you want to print two variables, you can do the following code:
But, if your goal is to print your variables with their names, you can use a special f-string feature:
Isn't that simple? The equal sign inside the curly brackets will print the content of the expression in the curly brackets and then its value.
It can be used for expressions as well.
|
Last 10 artitles
9 popular artitles
|
|
© 2020 MyCoding.uk -My blog about coding and further learning. This blog was writen with pure Perl and front-end output was performed with TemplateToolkit. |