From a36f6aeb2ce0cddd3bde8bd3ae45a264fb5cfa25 Mon Sep 17 00:00:00 2001 From: YONGS13 <52412571+YONGS13@users.noreply.github.com> Date: Tue, 20 Oct 2020 13:48:38 +0800 Subject: [PATCH] Hacktober-accepted Pls review my alternative approach. Thanks! --- set_theory_find_intersection.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/set_theory_find_intersection.py b/set_theory_find_intersection.py index be0ea91..497bd3d 100644 --- a/set_theory_find_intersection.py +++ b/set_theory_find_intersection.py @@ -34,3 +34,13 @@ ''' # YOUR TURN: Modify the FOR loop above +a = [1, 3, 9, 2, 5, 18, 3, 9, 2] +b = [0, 2, 9, 2] +intersection=[] +for i in range (len(a)): + for j in range (len(b)): + if a[i] == b[j]: + intersection.append(a[i]) +intersection=set(intersection) +print(intersection) +