Low Orbit Flux Logo 2 F

Python How To Concatenate Strings

We are going to show you how to concatenate strings with Python. This is probably almost one of the single easiest things we could cover.

To concatenate strings in Python just use the “+” operator like this:


a = "Test"
b = "String"
c = a + " " + b

In the above example we concatenate three strings. Two were held in variables and the other was a string literal. They were all concatenated into one using the “+” operator and saved to the variable c.

You could also do this directly within a print statement like this.


print( a + " " + b )

If you don’t want a space you can leave that out and just concatenate the two variables.


print( a + b )

To concatenate a string and an integer you would need to convert the string using the str() function like this:


n = 25
print( "Result: " + str(n)  )