We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 88c1caa commit 3fec4f9Copy full SHA for 3fec4f9
1 file changed
common_element_in_list
@@ -0,0 +1,29 @@
1
+def common_elements(list1,list2):
2
+ common = []
3
+ count=0
4
+ for i in list1:
5
+ for j in list2:
6
+ if(i==j):
7
+ common.append(i)
8
+ count=count+1
9
+ print(common)
10
+ print("Common elements in both list is : ",count)
11
+
12
+def common_elements_dict(list1,list2):
13
+ dict1={}
14
+ for element in list2:
15
+ dict1[element]=1
16
17
18
+ if dict1.get(i)!=None:
19
+ print(i)
20
21
+ print("Number of elements common are: ", count)
22
23
24
25
26
27
+l1=[2,4,6,8,10,12,14]
28
+l2=[3,6,9,12,15,18]
29
+common_elements_dict(l1,l2)
0 commit comments