Home > Backend Development > Python Tutorial > How to merge two lists in python

How to merge two lists in python

藏色散人
Release: 2019-07-06 11:18:22
Original
22748 people have browsed it

How to merge two lists in python

How to merge two lists in python?

How to merge two lists in python:

First open the code editor and enter the code compilation environment

How to merge two lists in python

The first method uses the addition method to implement list addition

a = [1,2,3]
b = [4,5,6]
c = a+b
Copy after login

How to merge two lists in python

Use the compiler to execute and the result c is [1,2,3,4,5,6]

How to merge two lists in python

The second method List addition can be completed through the extend method of python

Enter the code

a = [1,2,3]
b = [4,5,6]
a.extend(b)
Copy after login

How to merge two lists in python

Compile and execute, the result of a is [1,2,3,4 ,5,6]

How to merge two lists in python

Related recommendations: "Python Tutorial"

The above is the detailed content of How to merge two lists in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template