- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 −
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)
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]
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.
- Python – Rows with all List elements
- Python – Test if elements of list are in Min/Max range from other list
- Python – All replacement combination from other list
- Python – Adjacent elements in List
- Python – Maximum of K element in other list
- Python – Restrict Elements Frequency in List
- Python – List Elements Grouping in Matrix
- Python – Fractional Frequency of elements in List
- Python – Concatenate Rear elements in Tuple List
- Python – Extract elements from Ranges in List
- Python – Check alternate peak elements in List
- Python prorgam to remove duplicate elements index from other list
- Python – Check if elements index are equal for list elements
- How to combine list elements of different sizes in R?
- Python – Nearest occurrence between two elements in a List