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 trialMakan Fofana
Courses Plus Student 1,773 PointsMy .format program is not running. I have spent a good amount of time trying to figure it out.
I am currently working on printing using .format
name = "Makan"
subject = "Treehouse loves {}"
print(subject.format(name))
6 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Thierry,
The reason Task 2 is not passing is because of 2 things. First, the challenge did not ask for a print statement.
Second the .format
needs to format the string and placeholder assigned to subject
. Currently it is trying to format a variable.
So, you're on the right track, you just need to move the format to the string itself
name = "Makan"
subject = "Treehouse loves {}".format(name)
Hope that helps. :)
Zach Swift
17,984 PointsI pasted your code in as is and it passed.
Makan Fofana
Courses Plus Student 1,773 PointsYeah it still not going through for me
Zach Swift
17,984 PointsAre you getting an error message?
Zach Swift
17,984 PointsSorry for the confusion! I didn't notice there were 2 tasks on that one.
Makan Fofana
Courses Plus Student 1,773 PointsThank you both for your help.
Carlos José
Courses Plus Student 12,431 PointsIn still don't have much experience in Python but I got curious and observed that in all cases I found on the web no example has tried to call the method from a variable with a string, instead they show the method called directly from a string literal.
like : "Treehouse loves {0}".format(name);
Maybe you can try :
print("Treehouse loves {0}".format(name));