In this article, I'd like to share with you ways to Concatenate strings in python and a function that Concatenates multi strings.

method 1: Concatenate strings using "+" addition operation

Syntaxt

string + string

Example 1:


string_1 = "Hello "
string_2 = "Python"

#concatenate strings
concatenate = string_1 + string_2

print(concatenate)


output

Hello Python

Example 2:


print("Hello " + "Python")

output

Hello Python

method 2: Concatenate strings using join() built-in function

syntax

concatenate = "".join([string_1, string_2, ...])

Example 1:


string_1 = "Hello "
string_2 = "Python"

#concatenate strings
concatenate = "".join([string_1, string_2])

print(concatenate)

output

Hello Python

Bonus: joining endless of strings

in this part, we'll code a function that joining endless of string and return the result

Example:


#function
def string_concatenation(*args):
    #string
    string = " ".join(args)
    return string


#concatenate strings
print(string_concatenation("Python", "is", "The", "Best", "language", "in", "The", "Word"))    

output

Python is The Best language in The Word

English today is not an art to be mastered it's just a tool to use to get a result