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

Seamus Hannan
Seamus Hannan
509 Points

I cant figure out what is wrong with my code

It looks like I've done everything right, but It keeps giving me the 'bummer!"

name='seamus' subject='treehouse loves {}' print(subject.format(name))

the error says I need to use {} and format, but I've clearly used both, If i've used them wrong it doesn't say how.

strings.py
name='seamus'
subject='treehouse loves {}'
print(subject.format(name))
Seamus Hannan
Seamus Hannan
509 Points

didn't realize they would imbed my code, so disregard the in-line stuff up top.

2 Answers

Elad Ohana
Elad Ohana
24,456 Points

Hi Seamus,

The goal is to assign the subject variable to the full concatenated string as mentioned in the exercise. You're currently simply saving the string template that can be changed later, but you're not assigning your name value inside the string. There is no need to print the string. Also, make sure that the subject string is exactly as stated in the exercise as you need "Treehouse" to be capitalized as such. Try it out!

Seamus Hannan
Seamus Hannan
509 Points

cool I got it. I didn't realize I was meant to write it as:

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

All in the same line.

Thanks!