
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python program to find Union of two or more Lists?
Union operation means, we have to take all the elements from List1 and List 2 and all the elements store in another third list.
List1::[1,2,3] List2::[4,5,6] List3::[1,2,3,4,5,6]
Algorithm
Step 1: Input two lists. Step 2: for union operation we just use + operator.
Example code
# UNION OPERATION A=list() B=list() n=int(input("Enter the size of the List ::")) print("Enter the Element of first list::") for i in range(int(n)): k=int(input("")) A.append(k) print("Enter the Element of second list::") for i in range(int(n)): k=int(input("")) B.append(k) C = A + B print("THE FINAL LIST IS ::>",C)
Output
Enter the size of the List ::4 Enter the Element of first list:: 23 11 22 33 Enter the Element of second list:: 33 22 67 45 THE FINAL LIST IS ::> [23, 11, 22, 33, 33, 22, 67, 45]
- Related Articles
- C# program to find Union of two or more Lists
- Program to find union of two given linked lists in Python
- C# program to find Union of two or more Dictionaries\n
- C# program to concat two or more Lists
- C# program to find common values from two or more Lists
- Python program to find Intersection of two lists?
- Python program to find Cartesian product of two lists
- How to find the intersection between two or more lists in R?
- C# program to find Intersection of two lists
- Python program to find missing and additional values in two lists?
- Program to find minimum difference between two elements from two lists in Python
- GCD of more than two (or array) numbers in Python Program
- Python Program for GCD of more than two (or array) numbers
- C++ program to find union and intersection of two unsorted arrays
- Program to find median of two sorted lists in C++

Advertisements