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

Tito Das
Tito Das
198 Points

What is wrong here -- >> name = "Tito" >> str1 = "Treehouse loves {}" >> subject = str1.format(name)

What is wrong here --

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

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

2 Answers

andren
andren
28,558 Points

There is nothing inherently wrong with your code. But the challenge checker for these tasks can be pretty picky. Even if the result is correct if you did not achieve the result in the way that is expected your code will often be marked as wrong.

The problem in this specific instance is that you create the str1 variable and assign the message to it, you can complete this challenge without doing that. You can simply use format directly on the string as you assign it to the subject variable like this:

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

That is the way the challenge checker expects you to solve the problem, and as such is the only solution it will accept.

Tito Das
Tito Das
198 Points

Thanks andren. Yes, I just figured that. Keep tweaking till challenge checker is happy. Else, once u r happy with the results on ur terminal, proceed to the next lesson (keeping challenge checker unhappy) in the best interest of time..:-))

Can you give andren a "Best Answer" so this question will appear solved in the Community? Thx, alex

Tito Das
Tito Das
198 Points

Thx. Just did.