When I run this simple program in python I get an ascii error after "for line in file". I have tried many changes with no success. Why am I running into this issue?
Code:
flashcards = {}
def Gaelic():
file = open ("gaelic_flashcard_mode.txt", "r")
for line in file:
print("clear4")
line1 = line.rstrip().split("=")
key = line1[0]
trans = line1[1]
PoS = line1[2]
flashcards[key] = [trans, PoS]
print(flashcards)
Text file being read in (gaelic_flashcard_mode.txt):
I=mé=(pron) (emphatic)
I=mise=(n/a)
you=tú=(pron) (subject)
you=tusa=(emphatic)
y'all=sibh=(plural)
y'all=sibhse=(emphatic)
he=sé=(pron)
he=é=(n/a)
he=seisean=(emphatic)
he=eisean=(n/a)
she=sí=(pron)
she=í=(n/a)
she=sise=(emphatic)
she=ise=(emphatic)
him=é=(pron)
him=eisean=(emphatic)
her=í=(pron)
her=ise=(emphatic)
her=a=(adj)
flashcardswill only wind up with thetransandPoScorresponding to the lastkeyread for each of thekeys. I.e. you'll only have'her': ['a', '(adj)'], not['ise', '(emphatic)']or anything.:is not an ascii:.