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

James Shackelford
James Shackelford
501 Points

How do you complete task 2 of string concatenation ? I am having issues writing the variable for the tree + house.

name = ("what is your name") (The above passes)

if name == "treehouse" print("name + treehouse") (This fails)

name =( "tree + house") (this also fails)

name.py
name=("what is your name")
name = ("tree + house")

3 Answers

Matthew Rigdon
Matthew Rigdon
8,223 Points

Steps 1 and 2 are not related. So name should be your name. The treehouse variable is "Tree" + "house", which will concatenate the two words. You can see my example below:

name = "John"
treehouse = "Tree" + "house" # Make sure you capitalize 'Tree'
email_greeting = "{} loves {}".format(treehouse, name)
James Shackelford
James Shackelford
501 Points

Thank you I now see where I was going wrong.

Nick Tillman
Nick Tillman
12,595 Points

Yeah, the problem is where you are putting your quotation marks. For the + operator to work for concatenation, you have to remove it from the quotation marks. Right now, the Python interpreter isn't seeing the + as an operator because you have it inside your quotation marks. You just have one string. So if I want to concatenate "fire" and "place" to create "fireplace" I have to do it like this: "fire" + "place". Notice where the quotation marks are.

Also, while it won't create an error, just know that you don't actually need the parenthesis here. name = "string" works just fine.

Abhishek Gangadhar
Abhishek Gangadhar
9,467 Points

Hey James,

Its simple, all you have to do is add the seperate strings. You have included '+' sign inside a string, so its just another character in a String.

solution : treehouse = "tree" + "house"

James Shackelford
James Shackelford
501 Points

Thanks for responding but however is was not able to successfully complete task. Will keep trying and seeking help.