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.
Using the format()
method:
Watch a video course
Python - The Practical Guide
Using f-strings (Python 3.6 and above):
Both will output "My name is John".