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

Jovita Alphonse
Jovita Alphonse
313 Points

connecting strings

subject = "treehouse" + "loves"

strings.py
name = 'jovita'
subject = "Treehouse" + "loves" 

2 Answers

AJ Salmon
AJ Salmon
5,675 Points

Hi Jovita!

This challenge wants you to concatenate the string 'Treehouse loves' with your name, using your name variable that you already set. SO, subject should be equal to "Treehouse loves jovita". Don't forget to add a space to the end of your "Treehouse loves" string, so that there's a space between the word 'loves' and 'jovita'.

Jovita Alphonse
Jovita Alphonse
313 Points

Can i ask another question - I am getting hung up on task 2.
See Below

OK, now use .format() on the string "Treehouse loves {}" to put your name into the placeholder. Assign this to the variable subject (so start with subject =). You do not need to print() anything.

1 name = "jovita" 2 subject = "treehouse loves{}".format(name) 3

AJ Salmon
AJ Salmon
5,675 Points

In code challenges, the code engine looks for a very specific answer. You need to make sure that your code will output exactly what the challenge asks you to, otherwise it won't pass. So here, capitalize 'treehouse' and make sure there is a space between the word 'loves' and the curly braces. Example:

name = 'jovita'
subject = "Treehouse loves{}".format(name)
#gets the output
>>> subject
>>> 'Treehouse lovesjovita'

name = 'jovita'
subject = "Treehouse loves {}".format(name)
#gets the output
>>> subject
>>> 'Treehouse loves jovita'

Hope this helps!

AJ Salmon
AJ Salmon
5,675 Points

My pleasure! Happy coding :)