Python program to concatenate String using join() method

Python program to concatenate two string using joint() function

In this tutorial, we are going to learn writing a python program to concatenate two strings using python inbuilt join() method.

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 ‘pythonfun’.

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

                    then the output should be ‘learnpython’.

Our logic to concatenate two string using join() function

  • Firstly, take two strings as inputs from the user.
  • then, use string concatenation methods to join the strings together. Here we are using join() method.
  • And finally, return the concatenated string as an output of our program.

Algorithm to concatenate two string using join() function

Step1:  Start

Step2:   Take two strings as input from the user.

Step3: print “ ”.join( [string1, string2] )

Step4: Stop

Python code to concatenate two string using join() function

Output:

Explanation:

In this example, the two strings entered by the user are ‘quescol’ and ‘website’ after using the join() method which took two strings as iterable and returns the output as ‘quescolwebsite’.