How to concatenate two strings in Python
In this tutorial, we are going to learn how to concatenate the two strings in Python.
Concatenation means the joining of two strings into a single string.
To concatenate the two strings into a single string, we can use the +
operator in Python.
Here is an example:
a = "Hello "
b = "Python"
c = a + b
print(c)
Output:
Hello Python
We can also add a space between two strings like this:
a = "Hello"
b = "Python"
c = a +" "+ b
print(c);
Appending a string
To append a string to an existing string, we can use the +=
operator in Python.
Here is an example:
a = "Hello"
a += " Python"
print(a)
Output:
Hello Python