Aug 5, 2018

Python provides us with formatted strings.

A formatted string is a template in which words or spaces that will remain constant are combined with placeholders for variables that will be inserted into the string. For example, the statement

print(name, "is", age, "years old.")
contains the words is and years old, but the name and the age will change depending on the variable values at the time of execution. Using a formatted string, we write the previous statement as

print("%s is %d years old." % (name, age))