Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Python Data Types String Formatting

Adrian Caballero
Adrian Caballero
2,104 Points

.format method

Hi there,

I can't seem to get passed this question. I'm asked to use the .format() method to place my name into the string "Treehouse loves {}". I even ran this is the shell with no issue. Why can't I pass this quiz :/

strings.py
name = "Adrian" 
subject = "Treehouse loves {}"
subject.format(name)

Scan through the video and look at how Kenneth formats it. Third line isn't needed.

this may help!.

subject="treehouse loves {}".format(name)

1 Answer

Daniel Bourke
Daniel Bourke
3,870 Points

You're right. Your code does work. The challenge is asking for something very specific. I've run into this problem many times throughout challenges.

Try rearranging your subject variable so that it is all on one line and see how you go.

e.g.

subject = [YOUR CODE HERE]