;

Python Program to Concatenate the Strings


Tutorialsrack 26/04/2020 Python

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

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)
Output

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

Program 2: Python Program to Concatenate Strings Without Using + Operator

Python Program to Concatenate Strings Without Using + Operator
# 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)
Output

The Final String =  Tutorials rack

The Final String =  Python Programming Examples


Related Posts



Comments

Recent Posts
Tags