Python format() built-in function
From the Python 3 documentation
Convert a value to a “formatted” representation, as controlled by format_spec. The interpretation of format_spec will depend on the type of the value argument. [...].
Introduction
The format()
function in Python is a versatile built-in function that allows you to create formatted strings. It provides a way to embed values into a string, control their alignment, and specify their presentation, such as the number of decimal places or the padding.
The format() function formats a specified value into a specified format.
Examples
name = 'Micheal'
company = 'Dunder Mifflin'
print("My name is {0} and I work for {1}.".format(name, company))
# Formatting string (faster and easier)
print(f"My name is {name} and I work for {company}.")