import re f = open('testi/collodi_pinocchio.txt', mode='r', encoding='iso-8859-1') testo = f.read() testo=testo[1704:] testo=re.sub("'","' ", testo) testo=re.sub('[\.,;:\-?!]{1}','',testo) testo=testo.lower() testo=testo.split()