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 (2015) Python Data Types String concatenation

HARMANDEEP PANNU
HARMANDEEP PANNU
2,077 Points

OK! Make a new variable named subject that concatenates (uses the + sign) the string "Treehouse loves" and

OK! Make a new variable named subject that concatenates (uses the + sign) the string "Treehouse loves" and your name variable. You've probably received an email or two with this subject already!

strings.py
name = "Deja vu, huh?"
subject  = ("Treehouse loves " + "name")

2 Answers

Thomas Fildes
Thomas Fildes
22,687 Points

Hi Harmandeep,

Remember that you need to remove the quotation marks from the "name" part because you want the string that is stored inside your variable called name to be displayed. The parenthesis for the subject variable can also be removed.

Here is the correct code below where I have included some comments to explain it in further detail:

name = "Deja Vu"
# Stores the string Deja Vu inside the name variable

subject = "Treehouse loves " + name 
# Stores the string "Treehouse loves Deja Vu" inside the subject variable

Hope this helps! Happy Coding!!!

Hey there, Harmandeep!

You're close with your code, but you need to concatenate the variable to "Treehouse loves ". Currently, you're concatenating the string "name" with it. If you printed the subject variable, it would read "Treehouse loves name" when you want it to read "Deja vu, huh?", which is what the name variable is set to.

Remove the quotes from around "name" in the subject variable.

name = "Mike"
subject = "Treehouse loves " + name

Give that a try!

Hope this helps. :-)