Test Setup Failed
Push — master ( 0f6c81...eeed97 )
by Ken M.
44s
created

most_frequent()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
from collections import Counter
2
3
4
def most_frequent(data):
5
    return Counter(data).most_common(1)[0][0]
6
7
8
if __name__ == '__main__':
9
    # These "asserts" using only for self-checking
10
    # and not necessary for auto-testing
11
    print('Example:')
12
    print(most_frequent([
13
        'a', 'b', 'c',
14
        'a', 'b',
15
        'a'
16
    ]))
17
18
    assert most_frequent([
19
        'a', 'b', 'c',
20
        'a', 'b',
21
        'a'
22
    ]) == 'a'
23
24
    assert most_frequent(['a', 'a', 'bi', 'bi', 'bi']) == 'bi'
25
    print('Done')
26