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

Sahil Sharma
Sahil Sharma
4,791 Points

Hi, I am having a problem in submitting the code for string formatting.

I cannot understand why I cannot submit the code as I already tried the same code in a python shell of my computer's terminal and it worked perfectly.

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

3 Answers

Idan Melamed
Idan Melamed
16,285 Points

The challenge asks you to assign "Treehouse loves Akshay" to subject. But if you check your subject it is still only "Treehouse loves {}".

So either do

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

Or you could also do

name = "Akshay"
subject = "Treehouse loves {}".format(name)
Sahil Sharma
Sahil Sharma
4,791 Points

Although the first option still did not work, the "subject = subject.format(name)" one.