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

I need help with this Code Challenge

Ok, so I'm completely stuck on this code challenge. Any help would help be appreciated. Thank you.

strings.py
name = "Kenneth"
subject = "Treehouse " + "loves" 
print(subject + name)
Keifer Joedicker
Keifer Joedicker
5,869 Points
subject = "Treehouse " + "loves" 

Instead of concatenating these two strings together inside of a variable just type them out the one time you need them.

subject = "Treehouse loves "

Assigning data to a variable is only practical when you may need to reference that data again.

Reading closer the instructions ask us to create a variable called "subject" and assign the concatenate of "Treehouse loves" and the name variable. In doing so we should have the following lines of code:

name = "Kenneth"
subject = "Treehouse loves " + name

1 Answer

name = "Kenneth"
subject = "Treehouse " + "loves"  # (uses the + sign) the string "Treehouse loves" and your name variable.
subject = "Treehouse loves " + name
print(subject + name) # there's no need to this line