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 trialKyle McCartney
2,198 PointsI have to create a variable that puts treehouse and name into "X loves Y"
X is equal to treehouse and y equals name. The variable has to be email_greeting.
I'm stuck here...
name = ("Kyle")
treehouse = ("Tree" + "house")
2 Answers
Sreng Hong
15,083 PointsHi Kyle,
It's like this:
name = ("Kyle") #this is as x
treehouse = ("Tree" + "house") #this is as y
email_greeting = treehouse + " loves " + name
And don't forget the spaces around the word loves.
Hope this helps.
Tree Casiano
16,436 PointsHi Kyle, I use the formatting syntax below:
name = "Kyle"
treehouse = ("Tree" + "house")
email_greeting = "{} loves {}".format(treehouse, name)
The arguments you put in the .format() will replace the curly brackets in the string.
Kyle McCartney
2,198 PointsKyle McCartney
2,198 PointsThank you!