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 trialRobert Kwiat
5,349 PointsI am having trouble in this Python code challenge
Please help me, I am can define the first two variables but when i am asked to create a third variable that combines the first two into "x loves y" where variable 1 is y and variable 2 is x i get confused. Thanks!
2 Answers
Chris Dziewa
17,781 PointsI am guessing that you may have done what I just did when checking the code challenge you were working on. Make sure that you put the variable treehouse
first and not name
. At the very end it should say "Treehouse loves name" where name is your name. This is a solution using my name so if you would like to try it first, skip the next part of this answer.
name = "Chris"
treehouse = "Tree" + "house"
email_greeting = treehouse + " loves " + name
Notice that you need to add spaces around the word "loves" because there is no whitespace added when two strings are concatenated (added) together.
Jason Anello
Courses Plus Student 94,610 PointsHi Robert,
You should have something like this for task 2:
treehouse = "Tree" + "house"
You can do task 3 like that except you're joining 2 variables and a string together.
You can also use .format()
where you would have placeholders for X and Y and then pass into .format
the 2 variables for X and Y.
Post what code you have attempted if you're still stuck.
Chris Shaw
26,676 PointsPersonally like Kenneth I prefer the format
method instead, it's cleaner and offers a lot more visibility and functionality compared to just concatenating two strings together.