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

When I execute this code in online sandbox it works, but is not working here. Any suggestions? Thanks

name = "Hi, my name is {}" print(name.format("Justin")) subject = "Treehouse loves {}" print(subject.format(name))

strings.py
name = "Hi, my name is {}"
print(name.format("Justin"))
subject = "Treehouse loves {}"
print(subject.format(name))

2 Answers

Christopher Shaw
seal-mask
PLUS
.a{fill-rule:evenodd;}techdegree seal-36
Christopher Shaw
Python Web Development Techdegree Graduate 58,248 Points

The challage does not ask you to print anything, so remove the 2 line with print doing this can give unexpected results.

Add the .format(name) to the line where you assigned the variable subject. Doing this in the print line is not assigning it to the vaiable subject.

Harry Clarkson
Harry Clarkson
7,677 Points

Hi While that does work, to complete the challenge change the last two lines into one line. Have a go, if you get stuck just comment on this and I'll post the code.

Harry

Thank you!