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

how is this not right? not sure what it is specifically asking me to do first?

so how isnt this what they want here name = 'steve' subject = 'treehouse loves {}'.format(name)) print(subject)

strings.py
name='steve'
subject="treehouse loves {}"
print(subject.format(name))

2 Answers

andren
andren
28,558 Points

The instructions tell you to format the string and store the result in the subject variable, and that is all the task wants you to do. Like this:

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

They do not ask you to print it out. You should also note that I changed the string slightly, you had forgotten to capitalize the T in Treehouse. These challenges are very picky about strings, so even a minor typo like that is enough to make your code be marked as invalid.

thank you andren, unfortunately i did try this a few times exactly how you have it and copied/ pasted yours in and it still didnt work, so i wonder if i should refresh. this is why it was so frustrating and yeah i added print after the third time writing it too.

andren
andren
28,558 Points

That's weird I verified that the code I pasted passed the challenge before I posted so it should definitively work if you copy it, but the challenges can indeed be pretty buggy at times.

Yeah it finally worked. I thought I was going crazy. Again, thank you guys for helping so quickly. I'm really trying to dive into code and I'm really fascinated with it. I'm sure I'll be posting more with questions in other tests. If you can give any advice on what to do after python, of things I should add to my learning, that would be great. I'm Interested in it all, but wish to have a solid foundation of the most common programs in an appropriate order.

Nilay Jain
Nilay Jain
4,146 Points

Hello Steve, Below code should work. The challenge has two parts- On the first type- name = "steve" and on the next just add the below line- subject = "Treehouse loves {}".format(name)