Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » Python » Python programs

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



Here, we will learn how to concatenate two strings using + (plus) operator and assign the result to another string in Python?
Submitted by IncludeHelp, on September 07, 2018

In most of the programming language, we use plus operator (+) to concatenate two strings. Same as + Operator can also be used in Python to concatenate two strings in Python programming language.

In this program, there are two strings "Hello" and "World" and we have to concatenate these two strings along with a space between the strings and assign result 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





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.