In this Python program, we will learn how to concatenate the strings. In this program, we concatenate the string using two ways. In the first program, we use the + operator to concatenate the string and in the second program, without using + operator.
Here is the source code of the program to concatenate the strings.
Program 1: Python Program to Concatenate Strings Using + Operator
# Python Program to Concatenate Strings Using + Operator
# Take the Input From the User
str1 = input("Enter the First String: ")
str2 = input("Enter the Second String: ")
concat1 = str1 + str2
print("The Final String After Python String Concatenation = ", concat1)
concat2 = str1 + ' ' + str2
print("The Final After String Concatenation with Space = ", concat2)
Enter the First String: tutorials
Enter the Second String: rack
The Final String After Python String Concatenation = tutorialsrack
The Final After String Concatenation with Space = tutorials rack
# Python Program to Concatenate Strings Without Using + Operator
concat1 = 'Tutorials ' 'rack'
print("The Final String = ", concat1)
concat2 = ('Python ' 'Programming ' 'Examples')
print("The Final String = ", concat2)
The Final String = Tutorials rack
The Final String = Python Programming Examples
Comments