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 PointsMissing step for task 3 Python Basics
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!
If I take out lines 10 & 11, all I get is "bummer try again" When I try to add anything after line 5, I get "Task 1 is no longer passing.
I've tried many combos for the last 5hrs, haha! I am sure it's something super simple.
Any ideas?
name = "Drew"
nature = "Tree"
home = "house"
treehouse = nature + home
email_greeting = treehouse + name
if name == "Drew":
print("{} is cool! ".format(name))
else:
print("{} Treehouse ".format(treehouse))
else:
print("{} loves ".format(email_greeting))
1 Answer
Dan Johnson
40,533 PointsFor this challenge you won't need any conditional statements. If you did, they follow the structure:
if conditional:
#...
elif conditional:
#...
elif conditional:
#...
else:
#...
You can have 0 or more elifs and an optional else.
For email_greeting you can do either of the methods you were trying, just with slightly different formatting:
email_greeting = "{} loves {}".format(treehouse, name)
or
email_greeting = treehouse + " loves " + name
The challenge expects the string exactly as requested so you can run into problems if you add extra stuff.
Drew Bissonnette
309 PointsDrew Bissonnette
309 PointsThanks, I was able to finally get it using the 2nd option, I kept forgetting to space the " ".