String Formatting with Python 3’s f-Strings



Python 3.6 introduced a new way to format strings: f-Strings. It is faster than other string formatting methods in Python, and they allow us to evaluate Python expressions inside a string.

In this post, we’ll look at the various ways we can format strings in Python. Then we’ll have a deeper look at f-Strings, looking at how we can use it when displaying different data.

Traditional String Formatting in Python

Before we get into f-Strings, let’s have a look at the more “traditional” string formatting options available in Python. If you just want to skip to learning about f-Strings, check out the section String Formatting with f-Strings in this article.

String Concatenation

String concatenation means that we are combining two strings to make a new one. In Python, we typically concatenate strings with the + operator.

In your Python interpreter, let’s use concatenation to include a variable in a string:

name = "Python"
print("I like " + name + " very much!")

You would see the following output:

I like Python very much!

String concatenation works only on strings. If you want non-string data to be

To finish reading, please visit source site