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 concatenation

Oleksiy Kloc
Oleksiy Kloc
733 Points

print(subject.format(name)) should work but doesn't

Why not?

strings.py
name = 'alex'
subject = 'Treehouse loves {}'
print(subject.format(name))

2 Answers

I'm guessing because you aren't doing what the challenge wants you to do, which is just to use the plus sign to concatenate the string with your name value.

Oszkár Fehér
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Oszkár Fehér
Treehouse Project Reviewer

Hello format() method it should be used when you have to insert something in a text, int, float, str, byte, even objects

'Treehouse loves {} student'

and in

format('your name')

as

'Treehouse loves {} student'.format('your name')

will look

'Treehouse loves your name student'.

With + you add to the end or the beginning of the string and just string!! NO integer or other types