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 trialDrew Bissonnette
309 PointsWhat step am I missing?
I need to make a variable name treehouse and combine two strings for the word tree and house. Not sure what step I am missing.
name = "Drew"
name = "tree house"
if name == "Drew":
print("{} Drew is cool! ".format(name))
else:
if name == "tree house"
print("{} treehouse".format(name, name))
5 Answers
Jose Coto
11,466 PointsHi,
Great to know I was of help. As with everything, is about patience and trial and error!
José
Jose Coto
11,466 PointsHi,
The problem that I see in your code is that you are using the variable name twice. This makes that the second line of your code overrides the first. A hint that I hope it helps:
1) assgn different variable names for "tree" and house. E.g: nature = "tree" ho home = "house". 2) Then you just can concatenate strings with +. nature + home = "treehouse".
Hope this helps!
Drew Bissonnette
309 PointsI see what you are saying! So the format of my code is correct, I just need to assign the different variables, is that correct?
Drew Bissonnette
309 PointsAfter retying using the answer from above, I am told task one is no longer passing. I think I am mixing up two different codes, but not 100% sure. I am very news to this an eager to learn as much as I can! :)
name = "Drew" nature = "Tree" home = "house"
if name == "Drew": print(name + "is cool!") else: print( nature + "Tree" + home "house")
Jose Coto
11,466 PointsCould you remind me of the objective of this task. It seems to me you are really close, but I am not quite sure about what exactly is that you need to do.
Drew Bissonnette
309 PointsHey Jose, sure no problem. I actually just figured it out with your help and slowing down. I had to create a veritable name treehouse and then combine the two strings together to say "tree" and "house"
This is what my new code looked like and passed!
name = "Drew" nature = "Tree" home = "house" treehouse = nature + home if name == "Drew": print("{} Drew is cool! ".format(name)) else: print("{} Treehouse ",format(treehouse))
Drew Bissonnette
309 PointsAlright, it seems this time is a little more tricky for me.
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!
My code:
1 name = "Drew"
2 nature = "Tree"
3 home = "house"
4 treehouse = nature + home
5 email_greeting = treehouse + name
6 if name == "Drew":
7 print("{} is cool! ".format(name))
8 else:
9 print("{} Treehouse ".format(treehouse))
10 else:
11 print("{} loves ".format(email_greeting))
Get error task 1 no longer passing