I'm trying to figure out why KeyError: 0 pops up when I try to run the program containing the code.
The TXT File that I select contains the fallowing text.
In the hope that someone can help,
Josh
Code:
OpenDLG = wx.FileDialog(
self.win,
message='Please choose the quiz or quizes that you wish to use.',
defaultDir=os.getcwd(),
defaultFile='',
wildcard='*.*',
style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR)
self.AllWords = {}
paths = OpenDLG.GetPaths()
wordlistnum = -1
if OpenDLG.ShowModal() == wx.ID_OK:
for path in paths:
textfile = open(path)
words = textfile.readlines()
french = []
english = []
Pass = 'no'
wordlistnum +=1
for word in words:
if Pass == 'yes':
english.append(word[0:-2])
if '#english#' in word:
Pass = 'yes'
if Pass == 'no':
if '#english#' not in word:
french.append(word[0:-2])
self.AllWords.update(
{wordlistnum: {'French': french, 'English': english}})
The TXT File that I select contains the fallowing text.
Code:
bonjour aurevoir salut #english# hello good bye hey
Josh
Comment