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

Not sure what the task is looking for? My code works. https://teamtreehouse.com/library/python-basics/python-data-types

https://teamtreehouse.com/library/python-basics/python-data-types/string-formatting

Python basics string formatting task 2 is asking to use the .format() method to replace the variable in the string. I am unable to provide the correct answer. First it accepts " name = "Chris" " for the first task but when I try to use the .format() method to fill the " subject = "Treehouse loves {}" " by typing " print(subject.format(name)) " it will not accept this as the correct answer. I have tested this code in the treehouse workspace provided with the course and the code prints the subject with the name filled in correctly. Please help me understand how to answer the question being asked. The code works, the question might be asking for a sub-step I am not understanding. The instructions also, do not specify the use of the print() function but the video uses that function to explain the .format() method.

Thanks for any help you can provide, trying to get through this early speed bump and continue to learn to code python.

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

1 Answer

Sai Yamanoor
Sai Yamanoor
4,301 Points

You just have to do this:

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

You need not print anything.