Python Concatenate two strings and assign in another string by using + operator

Python Concatenate two strings and assign in another string by using + operator

Here, we will figure out how to link two strings utilizing + (in addition to) administrator and allow the outcome to another string in Python?

In the greater part of the programming language, we use in addition to administrator (+) to connect two strings. Same as + Operator can likewise be utilized in Python to link two strings in Python programming language.

In this program, there are two strings “Hello” and “World” and we need to link these two strings alongside a space between the strings and dole out the outcome to third string.

Example:

Input:
str1 = "Hello"
str2 = "World"

str3 = str1 + ' ' + str2
Output:
str3 = "Hello World"

Program:

# Python program of concatenate operator 

# input strings 
str1 = "Hello"
str2 = "World"

# concatenate and assign in another string 
str3 = str1 + ' ' + str2

# print strings
print "str1: ",str1
print "str2: ",str2 
print "str3: ",str3

Output:

str1:  Hello
str2:  World
str3:  Hello World

Recent Posts

error: Alert: Content is protected!!