Editor settings

General settings

Save settings

Learn to program with Python

Find the intersection of two lists #

Write a function find_intersection(list1, list2) that takes two lists as input and returns a new list containing the intersection of the two input lists. The intersection is defined as the common elements that appear in both lists.


Tests #

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