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

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,074 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,074 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.