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

Blake Rogers
Blake Rogers
3,069 Points

OK! Make a new variable named subject that concatenates (uses the + sign) the string "Treehouse loves" and your name var

OK! Make a new variable named subject that concatenates (uses the + sign) the string "Treehouse loves" and your name variable.

help me solve this

2 Answers

After setting name = "your name", you would create the the following line:

subject = "Treehouse loves " + name

Don't forget to add a space after loves, or else the name variable will be added to the string without it.

Robert Coll
Robert Coll
1,254 Points

This WAS NOT the correct answer according to them, but this brought up the correct answer in workspace

I tried this:

name = "bob" subject = "Treehouse loves " subject += name print(subject)

that should have worked for this problem but did not. The answer from Adam above will work for this question, not mine but I wanted to bring it up because it is right. Right??

Robert Coll
Robert Coll
1,254 Points

lol and imagine if there are no syntax or alignment issues either. I typed it in right when I commented, not sure why the code ended up looking like that.