How to Make Sure Values Are Placed in Correct Placeholders in Python


In this example we will show how to make sure the values are placed in the correct placeholders when using the format() method in Python.

Source Code

name = 'Jim'
age = 16
city = 'New York'

print('I am {0}, {1} years old, from {2}.'.format(name, age, city))

Output:

I am Jim, 16 years old, from New York.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments