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

Jeremy Pzygode
Jeremy Pzygode
4,499 Points

Using .format in the Challenge

So this is part of the python basics course. It's the one that wants us to use .format with name and subject.

This is my code: name = "Jeremy" subject = "Treehouse loves {}" print(subject.format(name))

Isn't this correct? It works on terminal for me.

This challenge keeps telling me I'm wrong

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi Jeremy! Your code may be functional, but that doesn't necessarily mean that it fills the requirements of the challenge. Keep in mind, that when doing these challenges it's always advisable to not do anything the challenge doesn't explicitly ask for. Even if functional, it can cause the challenge to fail. In your case, you're printing where they haven't asked you to.

name = "Jeremy" 
subject = "Treehouse loves {}".format(name)

So, if I remove the print part of your code, it passes! Happy coding! :sparkles: