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 trial

Python Python Basics (Retired) Ins & Outs Ins & Outs

Gokul Ravichandran
Gokul Ravichandran
209 Points

help on str.format

Finally, create a new variable named email_greeting that uses str.format to combine the treehouse variable, the word "loves", and the name variable with spaces between each item. eg: "Treehouse loves Andrew"

name.py
name="gokul"
treehouse="Tree" + "house"
email_greeting=print(treehouse +" loves " + name)

5 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points
name = "gokul"
treehouse = "Tree" + "house"
email_greeting = "{} loves {}".format(treehouse, name)

Note that the preferred style is to include spaces around the equals sign.

i did it!, Chris and it does not work email_greeting = "{} loves {}".format(treehouse, name) what is wrong with that so?!

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Hi Taha, it might related to your other code. Can you post all your current code?

Hi Chris, thanks for answering and your time as well :)

name = "Taha";
treehouse = "Tree" + "house";
email_greeting = "{}  loves  {}".format(treehouse, name)
Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Taha, your code is very close. You need only one space surrounding "loves". you have two. remove the extra spaces and your good to go1

Thanks, Chris Done, but tell me how did you know it ?

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

I've seen how picky the checker can be on whitespace and punctuation.

OKay, Thank you again :)