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

John Panagiotopoulos
John Panagiotopoulos
1,401 Points

python simple question

Finally, create a new variable named email_greeting that puts treehouse and name into "X loves Y" so X is treehouse and Y is name.

Typed this but didnt like it

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

4 Answers

Stone Preston
Stone Preston
42,016 Points

you are almost correct, you need to add spaces before and after loves so that it outputs correctly

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

this will output "Treehouse loves John". without the spaces it would be "TreehouselovesJohn"

As lauren said you could also use the .format function, either way will work. Personally i prefer using the format function so you dont have to worry about adding spaces onto the ends of your strings

email_greeting = "{} loves {}".format(treehouse, name)

I think you're supposed to use the {} and .format() to create this sentence, rather than just concatenating the variables and string together.

Stone Preston
Stone Preston
42,016 Points

either way will work, he just needs to add a space before and after loves

email_greetings= 'x' loves 'y' . format (treehouse, name)

MUZ141078 Lucent Ngwenya
MUZ141078 Lucent Ngwenya
2,618 Points

email_greeting="{} loves {}" . format (treehouse,name)