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

Giulia Merlo
Giulia Merlo
188 Points

Stuck again... can somebody help me seeing what I'm doing wrong in this challenge?

Hello!

Not sure what I'm doing wrong here and I got a bit stuck...

strings.py
name = 'Giulia'
subject = 'Treehouse loves {}'
subject.format(name)

1 Answer

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

I'm of the opinion that your code should work. However, the challenge is looking for you to do the string assignment to subject all on one line. See my code:

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

Keep in mind that challenges are very picky!

Giulia Merlo
Giulia Merlo
188 Points

thanks Jennifer! It's a bit confusing when you try them out in the workspace and they work there but not in the challenge...

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

Yup the devil is in the details. I've seen people fail challenges with fairly complicated code because they printed the result and didn't return it. I've fallen victim to it as well. Sometimes I believe this is what they want me to do, and I code it that way. Then I have to turn around and force myself to read it again and see what they ACTUALLY say (which generally turns out to be slightly different). You aren't alone here :)