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

what is wrong with this code: name = "stuart" subject = "Treehouse Loves {}".format(name)

what is wrong with this code

name = "Stuart" subject = "Treehouse Loves {}".format(name)

strings.py
name ="Stuart"
subject = "Treehouse Loves {}".format(name)

5 Answers

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

Hi,

your code is ok.

I copy and paste it and pass the challenge!

What's the problem?

I didnt pass the challenge - error must use format() and {}

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

Try to refresh the page and re-type the code!

I'm frustrated. I have been refreshing and re-coding for about 5 times but I'm still having the same error! "error must use format() and {}.

name = "Chloe" subject = "Treehouse Loves {}" .format(name)

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

Hi,

the code you have write here have space before .format(name).

Be sure that you don't have space between the string and the format function:

name = "Chloe"
subject = "Treehouse Loves {}".format(name)

Thank you Gianmarco.

John Hofford
John Hofford
6,990 Points

I think one of the code recommendations should be to "refresh your browser". I had a similar issue above and refreshed mine once and used the same code and it finally passed. After a dozen tries..