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

Jay Stratton
Jay Stratton
3,713 Points

question about the syntax of the challenge.

I have tried 3 different ways of syntax on this challenge and it tells me all of them are wrong. I don't understand what I am doing wrong. the variables have been assigned as directed. the three formatting methods I have used are: print(subject.format(name)) "treehouse loves {}".format(name) subject.format(name) I have used all three of the varies of syntax on python shell 3.5.1 and all three give the answer "treehouse loves jay" however I cannot seem to figure out what this challenge is asking. am I missing something? I cannot progress beyond this point and I do not understand what I am missing.

thanks, Jay

strings.py
name ="jay"
subject = "treehouse loves {}"
print(subject.format(name))

2 Answers

Carlos Federico Puebla Larregle
Carlos Federico Puebla Larregle
21,073 Points

There's no need to print the subject. You have to format the string directly. You could do it like this:

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

I hope that helps a little bit

Jay Stratton
Jay Stratton
3,713 Points

Ive tried it that way also. it keeps telling me (Bummer! Be sure to use the {} placeholder and the .format() method.) I have tried it the way shown, the way you described, as well as subject.format(name). It will not accept any of the methods, yet I do it on a shell and all three method work to get the desired result.

Carlos Federico Puebla Larregle
Carlos Federico Puebla Larregle
21,073 Points

It could be that you haven't capitalize the word "Treehouse" in your string.

Jay Stratton
Jay Stratton
3,713 Points

Treehouse is case sensitive. lessoned learned....lol. thanks for your help.