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

Challenge Task 2/2 of String Formatting (Python Basics) isn't checking my work correctly.

This is what showed up when I worked the challenge in Workspace: treehouse:~/workspace$ python
Python 3.5.0 (default, Apr 5 2016, 17:53:30)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.

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

But when I write the same code for the challenge, it says that it's incorrect. Am I missing something?

Thanks for your time!

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

2 Answers

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

No... and yes :smiley: The challenge wants the end value of subject to be Treehouse loves + name. So the end value here would be Treehouse loves AJ. Also, when dealing with challenges try not to do anything they don't explicitly ask for. Here you're printing. They never say to print. And while this code may be functional, it may cause the challenge to break. Here's what they're looking for.

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

thank you so much i almost went crazy

Thanks for your prompt and helpful reply, Jennifer!