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

Debdipta Dasgupta
Debdipta Dasgupta
431 Points

can't understand where am I going wrong. Tried a lot but couldn't crack the challenge Would appreciate a little help

I used the same code challenge in Treehouse Workspce and solved it.But somehow its not getting solved in the code challenge.Am I using the format method incorrectly?Couldn't understand.Need Help

strings.py
name="Deb"
goal="Treehouse loves {}"
subject=(goal.format(name))

2 Answers

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

Hi,

probably you can pass the challenge removing the external parenthesis in the variable subject.

Anyway, it's not necessary store the string Treehouse loves {} in a variable so you can do:

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

EDIT: your code pass if you remove the external parenthesis in the in the variable subject.

strings.py
name = "Deb"
goal = "Treehouse loves {}"
subject = goal.format(name) # removed parenthesis
Debdipta Dasgupta
Debdipta Dasgupta
431 Points

Thank you very much.Appreciate your help

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

This challenge checker is specifically looking for the format method being used directly on the patterned string:

name = "Deb"
subject = "Treehouse loves {}".format(name) # on same line