lexicon = {
'north': 'direction',
'south': 'direction',
'east': 'direction',
'west': 'direction',
'go': 'verb',
'kill': 'verb',
'eat': 'verb',
'the': 'stop',
'in': 'stop',
'of': 'stop',
'bear': 'noun',
'princess': 'noun',
1234: 'number'
}
def scan(sentence):
results = []
words = sentence.split()
for word in words:
word_type = lexicon.get(word)
results.append((word_type, word))
try:
number = int(word)
except ValueError:
pass
return results
So i am getting AssertionError: Lists differ: [(None, ‘1234’)] != [(‘number’, 1234)] when running this. I don’t quite understand how to implement the try and except into the for loop. Any ideas?