How do I put a variable’s value inside a string (interpolate it into the string)?
In Python, you can use the format() method or f-strings (available in Python 3.6 and above) to interpolate a variable's value into a string.
In Python, you can use the format() method or f-strings (available in Python 3.6 and above) to interpolate a variable's value into a string.
Using the format() method:
Interpolate a variable's value into a string using the format() method
python— editable, runs on the server
Info
Watch a video course: Python - The Practical Guide
Using f-strings (Python 3.6 and above):
Interpolate a variable's value into a string using the f-strings
python— editable, runs on the server
Both will output "My name is John".