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 trialBlake Rogers
3,069 PointsOK, so now use .format() on the string "Treehouse loves {}" to put your name into the placeholder. Assign this to the va
OK, so now use .format() on the string "Treehouse loves {}" to put your name into the placeholder. Assign this to the variable subject again.
help me with this
Blake Rogers
3,069 PointsThis
name = "Dylan" subject = "Treehouse loves {}" subject = print(subject.format(name))
name = "Dylan" subject = "Treehouse loves {}" print(subject.format(name))
name = "Dylan" subject = "Treehouse loves {}" subject = subject.format(name)
6 Answers
Robert Nardizzi
13,226 Pointsname =(Bobcat) subject = "Treehouse loves {}".format(name)
Ken Alger
Treehouse TeacherBlake;
You are definitely close and have the right idea. The challenge is looking for the format()
method to be directly attached to the string that is assigned to the subject
variable. We don't need to print anything.
Try doing the subject
variable step all in one line and see how that works.
Happy coding,
Ken
Blake Rogers
3,069 PointsPlease give me an example.
Ken Alger
Treehouse TeacherSure:
Here's an example, not the answer, but you should be able to get there.
name = "Blake"
statement = "{} can code in Python.".format(name)
Ken
Michael Murphy
14,097 PointsI didn't know it had to be on the same line, I tried to apply format on subject as a second step and that wasn't working. Your advice and example helped a lot.
Paul Mburu
1,098 PointsHi robert, I entered name="Bobcat" subject = "Treehouse loves {}".format(name)
and it didn't work.
Paul Mburu
1,098 PointsIt worked i forgot to put = after subject.
jacquesdiaquoi2
1,874 PointsI am new to programming but I just cannot get this on workspace but it works fine on the python shell. name = "jacques" subject = "Treehouse loves {} ".format(name) when I use print it works
Sandhya Akkinapalli
977 Pointsname = "Alex" subject = "Treehouse loves {}".format(name)
Ken Alger
Treehouse TeacherKen Alger
Treehouse TeacherWhat have you tried?