Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!