Bünyamin Sarı
1 min readJul 2, 2019

--

Interpolation and F-strings in Python 3.6

Hi! I have come across to another interesting topic in Python 3, especially in the version 3.6 formatting strings take a new turn.

When you initialize any variable, simply you can use it the strings as formatted to a string value, regardless to its latter data type. For examples:

name = Jenny

regards = f “Hi, {name} I am glad to see you!”

Hi, Jenny I am glad to see you!

So, If you look at the above example, after initializing the variable, you can use it in the strings with two curly parenthesis, this way it escapes the strings which it is in it.

This type of interpolation is called F-strings and it is available in the version 3.6 of Python. It was however available in the versions from 2 to 3.5 as;

name = 8

regards = “Hey, You are {} years old.”.format(name)

Anyways, newer version of Python makes it easier.

--

--