Python: Find identical items in multiple lists -


I have a list of arbitrary list, for example:

  [[1] , 2,3], [3,4,5], [5,6,7], [7, 8, 9]]  

Now I have a list that includes everyone Elements that are present in more than one list:

  [3,5,7]  

How do I do this?

Thank you!

Just like you would do it by hand:

  For the  seen = set () repeated = set (): I (L) in the set: if I saw: repeated. Add (i) other: seen.add (i)  

By the way, there is a liner (without the count of imports) that some people were demanding (should be less efficient than other approaches)

  reduce itertools by import (* Set. Inion, (strmp (set.intsection), combination (map (set, L), 2)))  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -