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

Kyle McCartney
Kyle McCartney
2,198 Points

I 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.py
name = ("Kyle")
treehouse = ("Tree" + "house")

2 Answers

Sreng Hong
Sreng Hong
15,083 Points

Hi 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.

Hi 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.