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 trialThomas Covington
Courses Plus Student 203 Pointshow do you tie two strings together in python
Having trouble tying the strings together. I know you use the + sign but where do I put it when I make my two strings?
2 Answers
Jacob Moyle
6,150 PointsHello Thomas,
You are correct, the +
operator (AKA concat
) between the two strings you wish to concatenate.
For example:
print "You can concatenate two " + "strings with the '+' operator."
str1 = "Hello"
str2 = "World"
str1 + str 2 #=> outputs "HelloWorld"
Here is a link for more examples.
Cheers,
Jacob
Charles Lee
17,825 PointsWhat you're looking for is called concatenation.
For example:
string1 = 'Hello '
string2 = 'World'
greeting = string1 + string2
print(greeting) # prints out 'Hello World'