- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python – Combine list with other list elements
When it is required to combine list with other list elements, a simple iteration and ‘append’ method is used.
Below is a demonstration of the same −
Example
my_list_1 = [12, 14, 25, 36, 15] print("The first list is :") print(my_list_1) my_list_2 = [23, 15, 47, 12, 25] print("The second list is :") print(my_list_2) for element in my_list_2 : my_list_1.append(element) print ("The result is :") print(my_list_1)
Output
The first list is : [12, 14, 25, 36, 15] The second list is : [23, 15, 47, 12, 25] The result is : [12, 14, 25, 36, 15, 23, 15, 47, 12, 25]
Explanation
Two lists are defined and displayed on the console.
The second list is iterated over, and each element of second list is appended to the first list.
This is the output that is displayed on the console.
- Related Articles
- Python – Test if elements of list are in Min/Max range from other list
- Python – Rows with all List elements
- Python prorgam to remove duplicate elements index from other list
- How to combine list elements of different sizes in R?
- Add list elements with a multi-list based on index in Python
- How to combine vectors of equal length into a list with corresponding elements representing a single element of the list in R?
- Delete List Elements in Python
- Python - Joining unicode list elements
- Python – Adjacent elements in List
- Python - Combine two lists by maintaining duplicates in first list
- Python – All replacement combination from other list
- Find the list elements starting with specific letter in Python
- List frequency of elements in Python
- Python – List Elements Grouping in Matrix
- Python – Restrict Elements Frequency in List

Advertisements