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 trialPeter Jespersen
278 Pointssubject.format(name) works in the console, why not in the quiz?
Stupid user issue here: I must be reading the question wrong because as the question states; printing subject.format(name) in the console works. But subject.format(name) in the quiz fails. I'm blind to something simple. What is it?
name = "Peter"
subject = "Treehouse Loves {}"
subject.format(name)
4 Answers
Jennifer Nordell
Treehouse TeacherHi there! There are two things going on here. First, you're doing the format on the subject string in place, but it's never assigned back into the subject variable. Use the format
on the same line with "Treehouse loves". Secondly, you've used the wrong capitalization on the word "loves". You've capitalized the "L".
When I fix these two issues, your code passes!
Hope this helps!
Peter Jespersen
278 PointsThe missing braces in this question are a typo on my part. The braces exist in the actual code and give me the Bummer error.
Jennifer Nordell
Treehouse TeacherPost your code as it is right now, and I'll take a look
Peter Jespersen
278 Pointsname = "Peter" subject = "Treehouse loves {}" .format(name)
Peter Jespersen
278 PointsIt pasted in one line but is 2 lines in the code.
Jennifer Nordell
Treehouse TeacherNow you have an extraneous space.
#you typed
subject = "Treehouse loves {}" .format(name)
#you meant to type
subject = "Treehouse loves {}".format(name)
Peter Jespersen
278 PointsHAHA! Yup! Thanks for helping the helpless. :)
Peter Jespersen
278 PointsPeter Jespersen
278 PointsLOL! I has format on the same line but never changed the capital L. The Challenge editor does not give you much feed back. :) Thanks!
Peter Jespersen
278 PointsPeter Jespersen
278 Pointssubject = "Treehouse loves" .format(name) Gives the following error: "Bummer! Be sure to use the
{}
placeholder and the.format()
method." This has to be related to the editor used in the course.....no? Thanks in advance!Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherOh you're close! But the Bummer message is correct. You've removed the
{}
from the original code you had. You were supposed to leave it in place. Theformat
method tells Python to insert the value of a variable wherever you have the curly braces, but you no longer have them.Take a look again at the code you posted here originally. and follow these steps:
.format(name)
on the same line with "Treehouse loves {}"Here's an example:
The variable
greeting
will now contain the string "Hi there, Peter"