Python Concatenate Strings

Concatenating means obtaining a new string that contains both of the original strings. In Python, there are a few ways to concatenate or combine strings. The new string that is created is referred to as a string object.

In order to merge two strings into a single object, you may use the + operator.

Example on string concatenation

In the below example, two original strings my_string1 and my_string2 are concatenated. To concatenate them, you use a plus operand to sum up both the strings, also specifying the space, generates the output as can be seen below.

To learn more about string manipulation, please see this video from our course, Regular Expressions in Python.

This content is taken from DataCamp’s Regular Expressions in Python course by Maria Eugenia Inzaugarat.