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 (Retired) Ins & Outs Ins & Outs

I got to the 3rd task, but I am getting error messages using: email_greeting = "treehouse" + loves + "name"

I am not sure what is wrong with my line 3. Please help.

name.py
name = "Jackson"
treehouse = "Tree" + "house"
email_greeting = "treehouse" + 'loves' + "name"

4 Answers

Hey Jackson, I hope you figured it out already but in case not.... The "+" signs ARE written outside the quotes. If you look at your variables specifically "name"

name = "Jackson"

The variable only contains your first name WITHOUT ANY SPACES. Take a look at this:

name = "Jackson   "

So in your second variable "treehouse" you are combining the VALUES "tree" and "house".

treehouse = "tree" + "house"

This is called concatenation...it is literally COMBINING or ADDING two strings together. The "+" sign just means to put the two things together. The difference is that you could add a SPACE to one of the values like so:

treehouse = "tree " + "house"

The value of your variable will now be "tree house" instead of "treehouse". So what I was saying before is that you can take your variables and add them to a string like the word "loves" but make sure to put SPACES around the word "loves" or else when you combine them with the "+" sign it would just say "TreehouselovesJackson" Adding the spaces makes the message clear. Hope this helps.

Hi Jackson

you are concatenating the strings 'treehouse' and 'name' rather than the variables you have created. In my example I have added a space after treehouse and your name.

name = "Jackson"
treehouse = "Tree" + "house"
email_greeting = treehouse+" "+"loves"+" "+name

I believe you can simplify your final variable "email_greeting" by adding whitespace before and after your string "loves" like so....

email_greeting = treehouse+" loves "+name

Aside from that, your explanation above is correct.

Could you explain why the "+" signs are not written outside of the quotes like the previous two lines?

The tutorial didn't mention that concatenating required "+" to be inside quotations for the variables.