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 is failing

below code command: name="Gaurav sharma" subject="treehouse loves {}" print(subject.format(str(name))) is working fine in workspace, but throwing error in quiz. Not sure if i got the wrong understanding of question. But also when i tried to print as "print(subject.format(name)) in workspace that also failed. Thanks for your time, Happy coding :)

strings.py
name= "gaurav sharma"
subject= "Treehouse loves {}"
print(subject.format(str(name)))

2 Answers

Rolando Aguilera
Rolando Aguilera
4,662 Points

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

That will be enough to complete the challenge! Keep coding!!

Nakisha Bowles
Nakisha Bowles
Courses Plus Student 1,010 Points

Gaurav Sharma, were you able to get pass 2.2 using these codes? I am still having trouble. Can you please help?

thanks mate, it worked fine. i was almost there, made a silly mistake

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

the challenge does not ask you to print anything. use the format method in the same line where you initialize subject, but without the str, name is already a string, it doesn't need to be cast as such.

tried: name= "gaurav sharma" subject= "Treehouse loves.format(name)"

it is also failing. tried below as well which also failed: name= "gaurav sharma" subject= "Treehouse loves {}" print(subject.format(name))