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

Please help!

Please help! I am new to programming and I am having difficulty with this seemingly simple problem. I feel that I must be missing something obvious.

name.py
name = "Paul"
treehouse = "Tree" + "house"
email_greeting = "treehouse" + "loves" + "name"

This is the problem: "Finally, create a new variable named email_greeting that puts the treehouse variable and the name variable into the sentence "X loves Y" but with treehouse for X and name for Y. Don't forget your spacing!"

3 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Paul;

Welcome to Treehouse!

In your email_greeting variable you are not using your name or treehouse variables. You are using strings and have not added the requested spaces. Your code is currently returning:

treehouselovesname

Do you recall from the video how to concatenate strings together?

Happy coding,

Ken

Hi Paul

you have stored the your string values in variables called name and treehouse. Your problem is instead of concatenating your variables treehouse and name to the email_greeting variable you are concatenating two strings names "treehouse" and "name".

I personally always like to use the format method of the string class where you substitute your values for the {} like this.

name = "Paul"
treehouse = "Tree" + "house" 
email_greeting = "{} loves {}".format(treehouse,name)

Great, thanks for the help!