PythonStringformat
count

formatString

zfill

Formats the string by inserting values into placeholders.

Syntax

str.format(*args, **kwargs)

Example

Enter values below to update the example in real time.

name
print
Name
Alice
Bob
years
old
name = "Alice"
age = 30
print("Name: {}, Age: {}".format(name, age))
# Name: Alice, Age: 30

print("{name} is {age} years old".format(name="Bob", age=25))
# Bob is 25 years old