Python program to concatenate two string

Python program to concatenate two string

In this tutorial, we are going to learn writing a python program to concatenate two strings.

Problem Statement

For two input strings that are given by the user, we need to join them together and return the final string as an output.

For example:

Case1: If the user gives the strings ‘python’ and ‘program’

                    then the output should be ‘pythonprogram’.

Case2: If the user gives the inputs as ‘learn’ and ‘python’,

                    then the output should be ‘learnpython’.

Our logic to concatenate two string

  • Firstly, take two strings as inputs from the user.
  • Then, use string concatenation methods to join the strings together
  • And finally, return the concatenated string as an output of our program.

Algorithm to concatenate two string

Step1:  Start

Step2:   Take two strings as input from the user.

Step3: print string1 + string2

Step4: Stop

Python code to concatenate two string

Output 1:

Explanation:

The user is given the input ‘quescol’ and ‘website’, now to join them together our program used the ‘+’ operator which joins two strings together and the final string generated is ‘quescolwebsite’.

Output 2:

Explanation:

The user is given the input ‘quescol’ and ‘website’, now to join them together our program used the ‘+’ operator which joins two strings together and the final string generated is ‘quescolwebsite’.