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

Arilesere Olaseni
Arilesere Olaseni
417 Points

String using .format()

I am doing the questions under strings.py. I think i am having a difficult time understanding the thing or not writing it correctly. I tried same code on spyder and it run giving the expected answer while it did not run here. What could be the problem. name = "Arilesere " subject = "Treehouse loves {} ".format(name) print (subject.format(name))# this line was not included on the code editor but i did include this on spyder and it run.

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

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing terrific and your output would look the same as what is expected, but it wouldn't be exactly the same. Your string contains one extra space at the end. If I remove the space after the curly braces and before the quotations, it passes!

You have written: {} ", but it should be {}" without the space inbetween. Otherwise, an extra space is added to the string. Hope this helps! :sparkles: