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

My string does not seem to work, can you help?

I keep getting the error: Remember that using '+' means that your string need extra space. I have no clue what this means as I have tried using different "

strings.py
name = "Nick"
subject = "Treehouse loves" + "name"

2 Answers

Andrew Young
PLUS
Andrew Young
Courses Plus Student 639 Points

If you want the result to be Treehouse loves Nick, you don't need quote for the name variable. for what error meaning is you'll need to add a space like "Treehouse loves " + "Nick" since + will only combine string if you don't add a space after loves the result will be Treehouse lovesNick

So your code should be something like this

name = "Nick";
subject = "Treehouse loves " + name 
# the subject variable will be "Treehouse loves Nick"

Hey thanks for the help Andrew, I really appreciate it. That worked out perfectly!

Andrew Young
Andrew Young
Courses Plus Student 639 Points

I just found out you're asking python question since I have a long time not touching Python you should change var to the way python to defined variable, the var method is for javascript but the idea is the same

Andrew Young
Andrew Young
Courses Plus Student 639 Points

And also help me mark my answer as best answer if it really helps you out Thanks!