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

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 :)