Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Python Data Types String Formatting

Justin Ricke
PLUS
Justin Ricke
Courses Plus Student 345 Points

Not sure what I am doing wrong ? name = "Justin" subject = "Treehouse loves {}" print(subject.format(name))

I thought this code wa formatted correctly but I am getting an error

strings.py
name = "Justin"
subject = "Treehouse loves {}"
print(subject.format(name))

3 Answers

Dan Garrison
Dan Garrison
22,457 Points

The format() should come immediately after your subject variable.

So it should look like:

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

When you print this, the format method inserts the name variable into the brackets

Steven Parker
Steven Parker
231,261 Points

You don't print anything for this challenge.

:point_right: You just do the formatting as part of the assignment of the variable subject.

I'm betting you can do it now without an explicit spoiler.