Literal String Interpolation


We’ve already gotten a lot of practice using the most basic form of creating output from our code: print() statements. It is possible within these statements to also include the letter at the beginning, which allows us to include variable names within curly braces as a more concise and convenient way to embed expressions inside strings. For example:

					name = "John"
age = 20
occupation = "Engineer"

print(f"{name} is {age} years old and works as an {occupation}")

Notice how we can embed expressions such as the strings name, age, and occupation within curly braces and inside the quotation marks of the string. In order to do this, it is required to start the string with the letter outside the quotations.

It’s that simple!

Replit Practice