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

concatenation

problem with the placeholders

name.py
name = 'dupree'
treehouse = "Tree" + "house"
email_greeting = ""X loves Y" but with" {}+"for X and"{}+" for Y".format(treehouse,name)

2 Answers

Samuel Webb
Samuel Webb
25,369 Points

You're trying to make it a little more complicated than you need to. In this example you're not using the .format() function. You can just use simple concatenation to achieve this. Your code should look like this for the final line:

email_greeting = treehouse + " loves " + name

The code below works ..... Dupree! you were on the right track( your initial attempt helped with this solution)

the first place holder {} stands for X and the second place holder {} stands for Y

 email_greeting = ("{} loves {} ".format(treehouse,name))
Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Why do you have parentheses around the entire string?

I assumed that because we are using python 3.4 a parentheses was needed. I've just realized that isn't the case :)

Dupree! Below is the new improved code :)

email_greeting = "{} loves {} ".format(treehouse,name)