Python
# Program to find union of two lists
list1 = input("Enter first list elements: ").split()
list2 = input("Enter second list elements: ").split()
union = list(set(list1) | set(list2))
print("Union:", union)Output
Enter first list elements: 1 2 3 Enter second list elements: 3 4 5 Union: ['1', '2', '3', '4', '5']
We use set union (|) to collect all distinct elements from both lists.