Storing frequencies
m = { } NEW_LINE for i in range ( len ( b ) ) : NEW_LINE INDENT if b [ i ] in m : NEW_LINE INDENT m [ b [ i ] ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT m [ b [ i ] ] = 1 NEW_LINE DEDENT DEDENT v = [ ] NEW_LINE for key , value in m . items ( ) : NEW_LINE INDENT v . append ( value ) NEW_LINE DEDENT