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

My .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

strings.py
name = "Makan"
subject = "Treehouse loves {}"

print(subject.format(name))

6 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey 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
Zach Swift
17,984 Points

I pasted your code in as is and it passed.

Yeah it still not going through for me

Zach Swift
Zach Swift
17,984 Points

Are you getting an error message?

Zach Swift
Zach Swift
17,984 Points

Sorry for the confusion! I didn't notice there were 2 tasks on that one.

Thank you both for your help.

Carlos José
PLUS
Carlos José
Courses Plus Student 12,431 Points

In 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));