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

Darren Taylor
Darren Taylor
1,052 Points

Can someone please help me, I'm trying to write "Treehouse loves" '+' followed by my name variable.

Can someone please help me, I'm trying to write "Treehouse loves" '+' followed by my name variable.

The challenge Task reads:

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

strings.py
name = "Darren"
subject = "Treehouse loves" '+' "Darren"

2 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

You don't need the quotes around the +, you need to just use it, like you would if you were adding two numbers together.

You should also use the name variable instead of re-typing your name. Again, no quotes, just the name of the variable, which is name

Darren Taylor
Darren Taylor
1,052 Points

Thanks for your feedback, I've tried what you told me to do such as:

  1. name = "Darren"
  2. subject = "Treehouse loves" + name

But my string is still coming up as incorrect, can you please give me an example. thanks

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

When you concatenate (combine) two strings, Python doesn't add any extra spaces or anything, so right now your code makes "Treehouse lovesDarren". How would you fix that?

Darren Taylor
Darren Taylor
1,052 Points

Thanks for your help, I just remembered that I needed to put a space between the quotation mark after the word "loves."