codescracker


python

Python Program to Concatenate String



« Previous Program Next Program »


Concatenate String in Python

To concatenate two string in python, you have to ask from user to enter the first and second string and start concatenating or appending both the string to form a new string say third string. After concatenation of both the string print the value of the third string as output as shown in the program given below.

Python Programming Code to Concatenate String

Following python program ask from user to concatenate two string:

# Python Program - Concatenate String
		
while True:
	print("Enter 'x' for exit.")
	string1 = input("Enter first string: ")
	string2 = input("Enter second string: ")
	if string1 == 'x':
		break
	else:
		string3 = string1 + string2
		print("String after concatenation =",string3,"\n")

Here is the sample run of the above Python program to demonstrate how to concatenate two string:

python concatenate two strings

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:


« Previous Program Next Program »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test