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

James Guido
James Guido
84 Points

Assigning variables to variables

The question goes: "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!"

I assigned (name) and (treehouse) to certain variables but cannot seem to assign the variables within variables..What do I do?

name.py
name=("james")
treehouse=('Tree'+'house')

2 Answers

Kevin Gary
Kevin Gary
3,788 Points

email_greeting = treehouse + " Loves " + name

should work.

by the way: name and treehouse are variables, and whatever they are set equal to is their value, not another variable.

name = "Tim" name is variable, Tim is the value (and a string.. hence name is of type string) if we write later, name = "John" name is variable, and now equal to value of John(also a string). neither Tim or John are variables, they are String values assigned to variables (in this case name)

Keerthi Suria Kumar Arumugam
Keerthi Suria Kumar Arumugam
4,585 Points

Here name and treehouse are your variables.

You can use it to get greeting = "{} loves {}".format(treehouse,name)