Hello, if you have seen any of my other posts you will know I am working on a script to make a "vocabulary test". I currently having it functioning nearly perfectly, except I get an error if I enter the wrong word.
Code:
def vocabtest():
for r in words.values():
count = 0
while count < 3:
print("What word does the following definition correspond with?")
print(r)
answer = raw_input("> ")
if words[answer] == r: #Error
print("Correct!")
count = 100000
elif words[answer] != r:
if count < 2:
count = count + 1
print("That is incorrect. Try again.")
elif count == 2:
count = count + 1
print("That is incorrect. The answer was",str(words[r]) + ".")
fail[r] = words[r]
If I enter the wrong word, I get a Key Error at line 8. Would anybody be able to help? Thanks in advance.