Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Susan Rodgers
Susan Rodgers
1,873 Points

I have a general Python question - why bother with 'format' when you can just concatenate text and variables.

... python3

name = "Susan" print ("My name is " + name) My name is Susan

print ("My name is {}".format (name)) My name is Susan ...

2 Answers

Kiefer H
Kiefer H
4,587 Points

I sometimes wonder why we use .format() at all when you just can f'{}'

Formatted strings just look better, and convey information a whole easier.

Jeff Muday
Jeff Muday
Treehouse Moderator 27,641 Points

That's a definitely fair question to ask.

You may run into a scenario where you have been asked to write a program that can run on different platforms (with the same code base). For example-- if you target only platforms that are running Python 3.6 and greater, then you can write f-strings -- earlier versions, unfortunately, aren't f-string aware.

As an aspirant-- often your first job might be maintenance of existing code. So you will definitely have to be familiar .format() and % operator as well as string concatenation.

Good luck with your Python journey!