Finding the most frequent character in a string

前端 未结 10 1894
执笔经年
执笔经年 2020-12-03 21:54

I found this programming problem while looking at a job posting on SO. I thought it was pretty interesting and as a beginner Python programmer I attempted to tackle it. Howe

10条回答
  •  失恋的感觉
    2020-12-03 22:20

    #file:filename
    #quant:no of frequent words you want
    
    def frequent_letters(file,quant):
        file = open(file)
        file = file.read()
        cnt = Counter
        op = cnt(file).most_common(quant)
        return op   
    

提交回复
热议问题