import operator
yz=2
alll={}
while yz==2:
    string = input('ใส่')
    if string == '0':
        break
    a = string.split('|')
    strr = []
    comp = {}
    for x in a:
        x.rstrip().lstrip()
        strr.append(x)
    for w in strr:
        a = strr.count(w)
        comp[w] = a
    alll.update(comp)
print(sorted(alll.items(), key=operator.itemgetter(1)))

ทำเพื่อจะหา frequency list