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

how to add two variables if these have characters in them? ex. name="ram"+"lakshman" subject="sita"+ "jayah"

how to add two variables if these have characters in them? ex. name="ram"+"lakshman" subject="sita"+ "jayah"

strings.py
name="Ranjan"+ "Verma"
subject="Treehouse"+"loves"

2 Answers

Tobias Helmrich
Tobias Helmrich
31,603 Points

Hey there,

you're concatenating correctly but the problem is that you don't have to concatenate each word in the two Strings but you just have to concatenate your name variable with the String in the subject variable like you did with the Strings like so:

name = "Ranjan Verma"
subject = "Treehouse loves " + name

I hope that helps! :)

thanks bro