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

Quiz is Broken???

If you look at the code you will probably think right off, "oh he forgot his print" Well not only did I try that a couple thousand times, it also states in the instructions not to put print.

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

This works perfectly in the workbench but isn't accepted by the quiz with or without "print()"

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

2 Answers

Daniel L.
Daniel L.
10,837 Points

That's so weird I don't know why it's not working in the challenge. You're right your code does produce the desired result in the shell...

In the meantime you could try this:

name = "Your Name"
subject = "Treehouse loves {}".format(name)
#you can also print if you like it
print (subject)

That seemed to have worked, thank you! I'm new to this so if you could get a mod on that it is Python Basics: String Formatting. Thanks again.

Daniel L.
Daniel L.
10,837 Points

I'm new too! Happy to help :)