Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!