menu
Python Join List - Javatpoint
Python Join List with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, operators, etc.

Python Join List - Javatpoint

In this topic, we will discuss how we can join two or more lists with different functions of Python. Before going through the concepts, let's take a brief introduction to the Python List. A Python List is the collection of multiples items that are grouped in the same name. It can store different data types (integer, string, float, etc.) items inside a square bracket [], which is separated by a (,) comma.

List.py

Output

When we join two or more lists together in a Python program, it gives a joined lists. And this process is called composition or joining of lists.

Let's discuss the different ways to join two or more lists in Python:

A join() function is used to join an iterable list to another list, separated by specified delimiters such as comma, symbols, a hyphen, etc.

Syntax

str_name: It is the name of the delimiter that separates an iterable list.

iterable: It is the list that contains a set of elements and joins with a delimiter.

Return Value: It returns a concatenated list that is separated by specified delimiters.

Join.py

Output

Prog.py

Output

Integer list: It collects all integers in a list called the integer list, and we cannot join two integer lists in Python using the join() function. Therefore, we use a map() function that converts an integer list into a string. After that, we use a join() function to join map() function results with appropriate delimiters.

Syntax:

In the above syntax, a map() function has two parameters, list_name, and str. Where list_name is the name of integers list and str represents the string. A map() function converts the list_name into the string (str).

Let's create a program to convert the given integers list into a string using the map() function and then join() function to join the list.

Convert.py

Output

An append() function is used to sequentially add or join each element of an iterable list at the end of another list using for loop. Let's create a simple program to add elements of a list at the end of another list using the append() function.

Append.py

Output

Let's create a simple program in Python to concatenate multiple lists using the chain() method by importing the itertools package.

New.py

Output

Let's consider an example to join two lists in Python using the (+) plus operator.

Mypro.py

Output

Consider an example to join two lists of in Python using * operator.

Mypro2.py

Output

Let's write a simple program to join two lists using extend() method in Python.

Prog.py

Output

SoapUI

RPA

Manual Testing

Cucumber

Appium

PostgreSQL

Solr

MongoDB

Gimp

Verilog

Teradata

PhoneGap

Aptitude

Reasoning

Verbal Ability

Interview

Company

Artificial Intelligence

AWS

Selenium

Cloud

Hadoop

ReactJS

Data Science

Angular 7

Blockchain

Git

Machine Learning

DevOps

DBMS

Data Structures

DAA

Operating System

Computer Network

Compiler Design

Computer Organization

Discrete Mathematics

Ethical Hacking

Computer Graphics

Software Engineering

Web Tech.

Cyber Security

Automata

C

C++

Java

.Net

Python

Programs

Control System

Data Mining

Hindi100

Lyricsia

Website Development

Android Development

Website Designing

Digital Marketing

Summer Training

Industrial Training

College Campus Training

Address: G-13, 2nd Floor, Sec-3

Noida, UP, 201301, India

Contact No: 0120-4256464, 9990449935

© Copyright 2011-2021 www.javatpoint.com. All rights reserved. Developed by JavaTpoint.