format() string method in Python

The format string method formats a string using placeholders {}.

Syntax string.format(values...)

Example:

Python

name = "Ashish"
age = 29
print("My name is {} and I am {} years old.".format(name, age))
# Output: My name is Ashish and I am 29 years old.