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

Drew Bissonnette
Drew Bissonnette
309 Points

Missing 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.py
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
Dan Johnson
40,532 Points

For 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
Drew Bissonnette
309 Points

Thanks, I was able to finally get it using the 2nd option, I kept forgetting to space the " ".