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 trialJohn Panagiotopoulos
1,401 Pointspython 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
42,016 Pointsyou 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)
laurenwolf
2,519 PointsI think you're supposed to use the {} and .format() to create this sentence, rather than just concatenating the variables and string together.
Stone Preston
42,016 Pointseither way will work, he just needs to add a space before and after loves
MUZ140638 Racheal Bandirai
2,742 Pointsemail_greetings= 'x' loves 'y' . format (treehouse, name)
MUZ141078 Lucent Ngwenya
2,618 Pointsemail_greeting="{} loves {}" . format (treehouse,name)