diff --git a/1.27/list_intersection.py b/1.27/list_intersection.py new file mode 100644 index 0000000..594cc3e --- /dev/null +++ b/1.27/list_intersection.py @@ -0,0 +1,19 @@ +""" +Exercise 1.27 - Intersection +""" + + +# Copyright (c) 2021. Pascal Syma. All rights reserved. + +def list_intersection(list1, list2): + """ + Return the intersection between two lists. + :param list1: First list + :param list2: Second list + :return: Intersection + """ + return [i for i in list1 if i in list2] + + +if __name__ == '__main__': + print(f'{list_intersection([1,3,6,78,35,55], [12,24,35,24,88,120,155]) = }')