davegimo

federica file

Mar 20th, 2021
547
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def f(file):
  2.     file = open(file,"r")
  3.     righe = file.readlines()
  4.     d = {}
  5.     for riga in righe:
  6.         parole = riga.strip().split()
  7.         for parola in parole:
  8.             for c in parola:
  9.                 if c in d:
  10.                     d[c] += 1
  11.                 else:
  12.                     d[c] = 1
  13.  
  14.     massimo = 0
  15.    
  16.     l = []
  17.  
  18.     for k in d:
  19.         l.append(d[k])
  20.  
  21.     l.sort()
  22.     print(l[len(l) - 3])
  23.  
  24. f("test.txt")
RAW Paste Data