Program to concatenate two lists in Python | extend function in python list
In this python programming guide, we are going to learn
-
program to concatenate two lists in python using extend in python list
Program to concatenate two lists in Python
The program uses extend in python to concatenate two lists in python is as follows:
# Owner : TutorialsInhand Author : Devjeet Roy
fruits = ["banana","apple","guava","mango"]
new_fruits = ["cherry","grapes","watermelon"]
fruits.extend(new_fruits)
print(fruits)
The output of the extend in python list program is as follows:
PS C:\Users\DEVJEET\Desktop\tutorialsInHand> python code.py
['banana', 'apple', 'guava', 'mango', 'cherry', 'grapes', 'watermelon']
Few important tips about the program
1. In python, we have extend() method which is used to join two lists.
2. It joins the list passed to it as an argument to the invoking list.
extend function in list in python program
This program uses extend function in python list or extend function in list in python.
Would you like to see your article here on tutorialsinhand.
Join
Write4Us program by tutorialsinhand.com
About the Author
Devjeet Roy
Full Stack Web Developer & Blockchain Enthusiast
Page Views :
Published Date :
Jun 28,2022