# Python | Print the common elements in all sublists

Given a list of lists, the task is to find the elements which are common in all sublist.

There are various approaches to do this task. Let’s discuss the approaches one by one.

Method #1: Using set

 `# Python code to find duplicate element in all  ` `# sublist from list of list ` ` `  `# List of list initialization ` `Input` `=` `[ [``10``, ``20``, ``30``, ``40``], ` `          ``[``30``, ``40``, ``60``, ``70``], ` `          ``[``20``, ``30``, ``40``, ``60``, ``70``], ` `          ``[``30``, ``40``, ``80``, ``90``], ] ` ` `  `Output ``=` `set``(``Input``[``0``]) ` `for` `l ``in` `Input``[``1``:]: ` `    ``Output &``=` `set``(l) ` ` `  `# Converting to list ` `Output ``=` `list``(Output) ` ` `  `# Printing answer ` `print``(Output) `

Output:

```[40, 30]
```

Method #2: Using `reduce `and `map`

 `# Python code to find duplicate element in all  ` `# sublist from list of list ` `import` `operator ` `from` `functools ``import` `reduce` ` `  `# List of list initialization ` `Input` `=` `[ [``10``, ``20``, ``30``, ``40``], ` `          ``[``30``, ``40``, ``60``, ``70``], ` `          ``[``20``, ``30``, ``40``, ``60``, ``70``],  ` `          ``[``30``, ``40``, ``80``, ``90``], ] ` ` `  `# using reduce and map ` `out ``=` `reduce``(operator.iand, ``map``(``set``, ``Input``)) ` ` `  `# Converting into list ` `out ``=` `list``(out) ` ` `  `# Printing output ` `print``(out) `

Output:

```[40, 30]
```

Method #3: Using` set.intersection `

 `# Python code to find duplicate element in all  ` `# sublist from list of list ` ` `  `# importing reduce  ` `from` `functools ``import` `reduce` ` `  `# function for set intersection ` `def` `func(a, b): ` `    ``return` `list``(``set``(a).intersection(``set``(b))) ` ` `  `# List of list initialization ` `Input` `=` `[ [``10``, ``20``, ``30``, ``40``], ` `          ``[``30``, ``40``, ``60``, ``70``], ` `          ``[``20``, ``30``, ``40``, ``60``, ``70``],  ` `          ``[``30``, ``40``, ``80``, ``90``], ] ` ` `  `# using reduce and set.intersection ` `out ``=` `reduce``(func, ``Input``) ` ` `  `# Printing output ` `print``(out) `

Output:

```[40, 30]
```

My Personal Notes arrow_drop_up

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.