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
The first method uses the addition method to implement list addition
a = [1,2,3] b = [4,5,6] c = a+b
Use the compiler to execute and the result c is [1,2,3,4,5,6]
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)
Compile and execute, the result of a is [1,2,3,4 ,5,6]
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!