I understand
a = max(set(lst), key=lst.count)
will derive most common element in a list
but how do you derive most common element in a list of list without using helper function?
For example
lst = [['1','2','3','4'],['1','1','1','1'],['1','2','3','4']]
The output should equal 1
.
When I try a = max(set(lst), key=lst.count)
it writes builtins.TypeError: unhashable type: 'list'
Can anyone please help me?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…