Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经坚持了一段时间了。
list= [['a', 'b', 'c', 'd'], ['a', 'a', 'b', 'c'], ['a', 'b', 'c', 'd'], ['a', 'a', 'b', 'c'], ['a', 'b', 'c', 'd']]
我如何找到最大数量的重复元素?例如,对于上面的列表,这将是 3,因为列表中有 [a,b,c,d] 的三个实例。
非常感谢
list1 = [['a', 'b', 'c', 'd'], ['a', 'b', 'c', 'd'], ['a', 'a', 'b', 'c'], ['a', 'b', 'c', 'd'], ['a', 'a', 'b', 'c']] print max(list1.count(e) for e in list1)