Ok...so, it's kind of easy.

The old method:

num = 6
mystr = 'number is %s' % num
print(mystr) # number is 6

The newer .format method:

num = 6
mystr = "number is {}".format(num)
print(mystr) # number is 6

The .format method using named variable (useful for when sequence can't be depended upon):

num = 6
mystr = "number is {num}".format(num=num)
print(mystr) # number is 6

The shorter f-string method: (thank you @mayur)

num = 6
mystr = f"number is {num}"
print(mystr) # number is 6
Answer from skeetastax on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-string-interpolation
Python String Interpolation - GeeksforGeeks
July 12, 2025 - String Interpolation is the process of substituting values of variables into placeholders in a string. Let's consider an example to understand it better, suppose you want to change the value of the string every time you print the string like ...
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ string-interpolation
Python String Interpolation
... String interpolation is a process substituting values of variables into placeholders in a string. For instance, if you have a template for saying hello to a person like "Hello {Name of person}, nice to meet you!", you would like to replace the placeholder for name of person with an actual name.
Discussions

Is there a way to interpolate variables into a python string WITHOUT using the print function? - Stack Overflow
Every example I have seen of Python string variable interpolation uses the print function. More on stackoverflow.com
๐ŸŒ stackoverflow.com
Does Python do variable interpolation similar to "string #{var}" in Ruby? - Stack Overflow
466 How do I put a variableโ€™s value inside a string (interpolate it into the string)? -2 how to pass string variable inside json data in python More on stackoverflow.com
๐ŸŒ stackoverflow.com
string - Variable interpolation in Python - Stack Overflow
Possible Duplicate: Unpythonic way of printing variables in Python? ... Is there a way for me to interpolate variables in strings instead? More on stackoverflow.com
๐ŸŒ stackoverflow.com
November 17, 2011
F-String In Python - A Modern Way To Perform String Interpolation
Good writeup, but in my opinion; this does not make the code easier to read - but that was never really the idea behind Python in the first place, otherwise we would have a switch/case. More on reddit.com
๐ŸŒ r/pythontips
9
41
January 8, 2023
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ python-string-interpolation
Python String Interpolation: A Beginner's Guide | DataCamp
February 13, 2025 - Learn about Python string interpolation, its purpose, and when to use it. Includes practical examples and best practices. ... Get your team access to the full DataCamp for business platform. Suppose you want to output a person's name and profession. You could write a simple program as follows. # Define variables name = 'Mark' profession = 'Astronaut' age = 7 # Output info output_string = ('My name is ' + name + ', I am ' + str(age) + ' years old ' + 'and my profession is ' + profession + '.') print(output_string)
๐ŸŒ
Real Python
realpython.com โ€บ python-string-interpolation
String Interpolation in Python: Exploring Available Tools โ€“ Real Python
July 5, 2024 - The first two fields hold the variables, and the third field holds an expression. Itโ€™s important to note that Python evaluates f-strings at runtime. So, in this example, x, y, and x + y are evaluated and interpolated into the string literal when Python runs the line of code containing the f-string.
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ string-interpolation-python
Python String Interpolation: 4 Methods (with Code)
November 10, 2023 - String interpolation is a powerful feature in Python that allows for the dynamic insertion of variables into strings. It enhances code readability, simplifies string formatting, and provides flexibility in generating output.
๐ŸŒ
Python Central
pythoncentral.io โ€บ python-string-interpolation-a-comprehensive-guide
Python String Interpolation: A Comprehensive Guide | Python Central
March 1, 2024 - You can then use the .substitute() method to indicate the substitution values. Now, let's see these four methods of string interpolation in action. Using the % character is perhaps the most straightforward way to interpolate strings, at least ...
Find elsewhere
๐ŸŒ
Real Python
realpython.com โ€บ lessons โ€บ interpolating-variables-string
Interpolating Variables Into a String (Video) โ€“ Real Python
Back here in a REPL, Iโ€™ll have you try out variable interpolation. You can specify a variableโ€™s name directly in an f-string literal, and Python will replace the name with its corresponding value.
Published ย  October 1, 2019
๐ŸŒ
Linode
linode.com โ€บ docs โ€บ guides โ€บ python-string-interpolation
An Introduction to Python String Interpolation | Linode Docs
May 20, 2022 - During string interpolation a string literal is evaluated and if any placeholders are present, they are substituted by the indicated variable values. String interpolation helps reduce repetition in code and allows for dynamic string substitution.
๐ŸŒ
iO Flood
ioflood.com โ€บ blog โ€บ python-string-interpolation
Python String Interpolation | Learn 3 Efficient Methods
July 5, 2024 - In the simplest terms, string interpolation is a method of substituting values into placeholders in a string. In Python, this is achieved using specific syntax that allows you to insert variables directly into strings.
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ String_interpolation
String interpolation - Wikipedia
3 days ago - String interpolation is common in many programming languages which make heavy use of string representations of data, such as Apache Groovy, Julia, Kotlin, Perl, PHP, Python, Ruby, Scala, Swift, Tcl and most Unix shells. There are two main types of variable-expanding algorithms for variable interpolation:
๐ŸŒ
Python
peps.python.org โ€บ pep-0498
PEP 498 โ€“ Literal String Interpolation | peps.python.org
However, in f-strings, you would need to use a literal for the value of 'a': ... This difference is required because otherwise you would not be able to use variables as index values:
๐ŸŒ
Python
python.org โ€บ dev โ€บ peps โ€บ pep-0498
PEP 498 -- Literal String Interpolation | Python.org
August 1, 2015 - Because the compiler must be involved in evaluating the expressions contained in the interpolated strings, there must be some way to denote to the compiler which strings should be evaluated. This PEP chose a leading 'f' character preceding the string literal.
๐ŸŒ
Reddit
reddit.com โ€บ r/pythontips โ€บ f-string in python - a modern way to perform string interpolation
r/pythontips on Reddit: F-String In Python - A Modern Way To Perform String Interpolation
January 8, 2023 - f-string is also called Formatted String literal and is a convenient way to interpolate variables into the string. Here's how to interpolate strings using f-string๐Ÿ‘‡๐Ÿ‘‡ ยท F-String In Python - A Modern Way To Perform String Interpolation Share
๐ŸŒ
Analytics Vidhya
analyticsvidhya.com โ€บ home โ€บ 10 python string interpolation approaches
Python String Interpolation: Enhancing Code Readability
May 21, 2024 - It is a powerful technique in Python that allows us to embed expressions inside string literals. It provides a convenient way to combine variables, expressions, and even functions with strings, making our code more readable and concise.
๐ŸŒ
Real Python
realpython.com โ€บ python-f-strings
Python's F-String for String Interpolation and Formatting โ€“ Real Python
November 30, 2024 - An f-string in Python is a string ... {}. To include dynamic content in an f-string, place your expression or variable inside the braces to interpolate its value into the string....
๐ŸŒ
Real Python
realpython.com โ€บ python-string-formatting
Python String Formatting: Available Tools and Their Features โ€“ Real Python
December 2, 2024 - For example, hereโ€™s how you can do some string interpolation using an f-string: ... In this quick example, you first have a Python variable containing a string object, "Bob". Then, you create a new string using an f-string. In this string, you insert the content of your name variable using a replacement field.