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

I cant figure this one out!

i type in

name = elvis subject = "Treehouse loves " + name

and get error message like it looks like task 1 is no longer passing? what does it mean? and also why is it a huge space after the word loves why cant i type in "Treehouse loves" with no sace after loves?

this is making me angry....

plz help

strings.py
subject = "Treehouse loves " + name

2 Answers

Wesley Trayer
Wesley Trayer
13,812 Points

name = elvis subject = "Treehouse loves " + name

OK, in what you wrote, "elvis'' has no quotation marks around it, causing task 1 to fail.

As for the space after "loves", if there were no space after "loves", the output would look like this: "Treehouse loveselvis" If you put the space after "loves" the result is: "Treehouse loves elvis" :)

instead of making space can i make "" ?

for an example "treehouse loves" "" "elvis"

Wesley Trayer
Wesley Trayer
13,812 Points

example "treehouse loves" "" "elvis"

a = "Treehouse loves"   "" #without a space in the quotes
b = "elvis"
c = a + b
print (c)
'Treehouse loveselvis'

a = "Treehouse loves"   " " #with a space in the quotes
c = a + b
print (c)
'Treehouse loves elvis'

c = "Treehouse loves" "" "elvis"
print (c)
'Treehouse loveselvis'

I tried this in the python shell, and here are my results.

Does this answer your question?