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

or porat
or porat
684 Points

cant pass this question

its ask me to make a varible called "subject" = 'treehouse loves' and use the + key with my name varible. so i wrote: name = 'or' subject = 'treehouse loves' + 'or' were did i go wrong?

thanx!

strings.py
name = 'or'
subject = "treehouse loves" + 'or'
or porat
or porat
684 Points

i mean why i need extra spaces?

3 Answers

name = 'or'
subject = "treehouse loves" + 'or'

Would result in "Treehouse lovesor"

name = 'or'
'treehouse loves ' + name

note the space after loves.

jacksonpranica
jacksonpranica
17,610 Points

Basically when you use the string concatenation, your code:

name = 'or'
subject = "treehouse loves" + 'or'

Will print out "treehouse lovesor"

You need an extra space at the end of "treehouse loves " <--- see how there's a space between the word loves and the " (quotation mark)?

This will help the sentence print out like "treehouse loves or" with a space between loves and the word or. Treehouse is telling you you are wrong as a way to make sure you make sure to add spaces so when you bring words together they have a space between them.

so the correct code is

name = 'or'
subject = "treehouse loves " + 'or'

OR YOU CAN USE 

name = 'or'
subject = "treehouse loves " + name