To label something in Python, you can use the print()
function to output the text that you want to label. Here's an example:
main.py35 chars3 lines
In the code above, we create a variable called name
and assign the value "John" to it. Then, we use the print()
function to output the text "Name:" followed by the value of the name
variable.
You can also use the format()
method of a string to insert variables into a string. Here's the same example using format()
:
main.py45 chars3 lines
The output of both examples will be:
main.py11 chars2 lines
gistlibby LogSnag