Why do we use join() function in Python?

The join() is defined as a string method which returns a string value. It is concatenated with the elements of an iterable. It provides a flexible way to concatenate the strings. See an example below.

str = “Rohan”
str2 = “ab”
# Calling function
str2 = str.join(str2)
# Displaying result
print(str2)
Output:

aRohanb