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.

Python Python Basics (2015) Python Data Types String Formatting

Oliver Guevarra
Oliver Guevarra
918 Points

String Formatting Help

Having trouble with the string formatting objective.

I've entered this code,

name = "My Name" subject = "Treehouse loves {}".format(name)

When I check my work its telling me the code is wrong.

1 Answer

Hi there!

Your code is actually perfect. The only thing you'll need to adjust, if I'm right that your code is exactly as you've put it above, is where you define the subject and the name. You can't do both on the same line, so you'd have to make it:

name = "My Name"
subject = "Treehouse loves {}".format(name)

Actually, he didn't_put it on the same line. It's just the Treehouse community posts automatically deletes newlines, so you need to use two newlines to tell the output to actually put a newline.

Like this. Also, in my post box at this moment when I'm typing this, I actually put one newline after the "Like this" message but this newline will be deleted.