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

Jamaru Rodgers
Jamaru Rodgers
3,046 Points

Code Challenge Broken!!

While formatting this bit of code, I've gone back many times and even taken pics of the video before this code challenge to make sure I'm not making an error. I also ran this same syntax in the python 3 shell on my computer and it worked, so I know its not me. What do I do, Treehouse??

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

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Jamal,

While your code may work in the shell, it is not what the challenge asked you to do. So, the challenge isn't broken. Your answer just isn't the correct one the challenge wants.

It didn't ask for a print statement. So that needs to be deleted. It just asks you to use format method on the string to make the string ... and assign it the the subject variable.

The corrected code will only be two lines:

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

Keep Coding! And remember, the challenges and very specific and very strict. :dizzy:

Jamaru Rodgers
Jamaru Rodgers
3,046 Points

Thanks to all of you for responding, and I do apologize. I will try this again lol!!

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

You're close here! It wants the formatted string assigned to the variable subject. The entire string. We do this in one line of code. Take a look at what it's looking for. The challenge isn't broken.

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

Almost. But they didn't ask you to print. Just to reassign the formatted result back to subject:

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