Editor settings

General settings

Save settings

Learn to program with Python

Find the union of two lists #

Write a function find_union(list1, list2) that takes two lists as input and returns a new list containing the union of the two input lists. The union is defined as the set of all distinct elements that appear in either of the lists.


Tests #

  • find_union([1, 2, 3, 4, 5, 6, 7], [4, 5, 6, 7, 8]) should return [1, 2, 3, 4, 5, 6, 7, 8]
  • find_union([5, 6, 7, 8], [6, 7, 8, 9, 10, 11]) should return [5, 6, 7, 8, 9, 10, 11]
  • find_union([1, 2, 3], [4, 5, 6]) should return [1, 2, 3, 4, 5, 6]
Output will be displayed here