Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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?


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)