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

Ins and Outs Challenge question

In task 3 of 3 of this challenge I'm trying to understand why there needs to be a space between the quotation marks and love. Here's the entire code that works below:

name = "David"
treehouse = "Tree" + "house"
email_greeting = treehouse + " loves " + name

When I tried it without the spaces the code failed to pass. When adding the spaces it passed. Thoughts?

3 Answers

Dave McFarland
STAFF
Dave McFarland
Treehouse Teacher

Hi David Carapezza

Without the spaces in the string " loves " you'll end up with "TreehouselovesDavid" in the email_greeting variable. When combining string values you often need to add spaces just to make sentences that are readable such as "Treehouse loves David"

Thanks Dave for helping me understand!

David,

Unless Treehouse has some specific rule requiring spaces, this should pass (with or without spaces in the quoted string). Spaces look better, but they're not a Python requirement.

name = "Roberto" treehouse = "Tree" + "house" email_greeting = "{} loves {}".format(treehouse, name)

This worked for me, try think as of replacing the curly braces with the variables you put in the format :) Good luck!