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

creating and combining new variable in Python

create a new variable named email_greeting that combines the treehouse variable, the string "loves", and the name variable with spaces between each item. here's what I did email_greetingtreehouse = "loves" + "name" my result was I keep getting it wrong. do not understand please Help!!!!

name.py
name = "terence" 
treehouse = "Tree" + "house"
email_greetingtreehouse = "loves" + "name"

3 Answers

Hey Terence!

Your first two steps are correct: you created two variables named name and treehouse and assigned them the appropriate string values. So far so good!

Where things go wrong is the third line. The challenge asks you to create a third variable named email_greeting, but you named yours email_greetingtreehouse. So, the first thing to do is put an equals sign = after email_greeting.

The next thing to fix is to leave quotation marks off of both name and treehouse. The reason you leave them off is because these are variable names, but if you put them in quotation marks, the computer will read them as strings. It is proper to have quotation marks around "loves" though, because that is a string.

The next thing to do is to make sure and add a space on either side " loves ". The reason you have to do this is because the strings you assigned on the first two lines don't have any spaces in them. So, if you put them together with "loves" instead of " loves ", the printed email_greeting would read "Treehouselovesterence" instead of "Treehouse loves terence".

Lastly, you need to make email_greeting equal to a variable + a string + a variable, as the challenge is requesting. Specifically, what they are looking for is treehouse + " loves " + name. That way, when they use the variables you've assigned above, the printed message will read "Treehouse loves terence" just like the challenge is looking for.

I hope this helps!

Be Well, Graham Arthur Mackenzie

Thanks very much :)

C H
C H
6,587 Points

Think of the variable name as representing exactly what it = for a string, so the quotation marks are already included as a part of it.

name = "Terence"
treehouse = "Tree" + "house"
#This will become "treehouse" as the two strings become one. So, "red" + "blue" would become "redblue"

email_greeting = treehouse + " loves " + name
#no quotes on variable names and the spaces need to be explicit to show, see the spaces around " loves " instead of "loves"

Sure thing! If my response answered your question successfully, it would mean a lot to me if you selected it as the best answer to your question.

Thanks! and Be Well, Graham