How to Format Selected Multiple Parts of a String in Python


In this example, we will learn how to format selected multiple parts of a string using the format() method in Python.

Source Code

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

print('I am {}, {} years old, from {}.'.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
Advertisement