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
Chandana Gutta
678 PointsI am stuck at this, I ran the same piece of code on my local IDE and it works fine somehow it's throwing an error here
Question:
OK, now use .format() on the string "Treehouse loves {}" to put your name into the placeholder. Assign this to the variable subject (so start with subject =).
Code:
name= 'Chandana' subject = "Treehouse loves {}" print(subject.format(name))
Error:
Bummer! Be sure to use the {} placeholder and the .format() method.
4 Answers
james south
Front End Web Development Techdegree Graduate 33,271 Pointsif it doesn't ask you to print, don't print. just set the variables as requested.
james south
Front End Web Development Techdegree Graduate 33,271 Pointsinstead of subject = "Treehouse loves {}" print(subject.format(name)) try it all on one line, i think that's what it wants. subject = 'treehouse....{}'.format(name) like you have.
Chandana Gutta
678 PointsI was just playing around with the solution to make it work! but actually even without print it doesn't work and gives the same error!
William Warren
2,519 PointsJames is correct, .format() only works when it is attached to a string, and it has variables in its parameters to stick in the string.
Gaurav Sharma
Courses Plus Student 964 PointsGaurav Sharma
Courses Plus Student 964 Pointsdid you find any solution?? i tried same with below command: name="Gaurav sharma" subject="treehouse loves {}" print(subject.format(str(name)))
worked in workspace, but failing here. not sure if i have a wrong understanding of question.?? error is : Be sure to use the
{}placeholder and the.format()method. task is to : format() on the string "Treehouse loves {}" to put your name into the placeholder. Assign this to the variable subject (so start with subject =). and name is defined already.