What happens is that I made a program that counts words in txt files in python, I try it for some files in English but when the files have characters like - ----- or ñ it appears Error :
'ascii' codec can not decode byte 0xc3 in position 43: ordinal not in range (128)
Does anyone know what the problem might be? Thanks in advance. :)
Code
archivo = input("Ingresa el nombre del archivo\n")
ahandle = open(archivo)
counts = dict()
for line in ahandle:
words = line.split()
for word in words:
counts[word] = counts.get(word, 0) + 1
bigcount = None
bigword = None
for word, count in counts.items():
if bigcount is None or count > bigcount:
bigword = word
bigcount = count
print(bigword, bigcount)