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

Ezekiel Obeisun
Ezekiel Obeisun
230 Points

what does the question mean by using the + sign for extra space?

It states the + needs more space for the subject to concatenates

strings.py
name = "Akin"
subject = "Treehouse loves"

2 Answers

andren
andren
28,558 Points

When you concatenation strings you essentially merge them together. If you merged "Treehouse loves" and "Akin" together you would get the string "Treehouse lovesAkin". As you can see the merged string is not space properly. This is due to the fact that no spacing is added when strings are concatenated, and there was no space at the end of or start of either string.

The solution is pretty simple, just add a space a space in one of the strings, for example:

name = "Akin"
subject = "Treehouse loves " + name

That code would produce the desired string with proper spacing, since there is now a space at the end of the subject string. You could achieve the same result by adding a space at the start of the name string.

Ezekiel Obeisun
Ezekiel Obeisun
230 Points

Yeah, Thank You. I was doing that, but I figured out the spacing in between the ending of "Treehouse loves "