I keep receiving SyntaxError message on ex41.py OR oop_test.py, and I've run through the whole script, everything is exactly as it is in the book, but I keep getting this - the variable {answer} is seemingly only defined in the try: section, so I have no clue why I am getting this SyntaxError.
***:hardway ***$ python ex41.py english
File "ex41.py", line 76
print(f"ANSWER: {answer}\n\n")
^
SyntaxError: invalid syntax
Here is the try: section, where the variable is at:
try:
while True:
snippets = list(PHRASES.keys())
random.shuffle(snippets)
for snippet in snippets:
phrase = PHRASES[snippet]
question, answer = convert(snippet, phrase)
if PHRASE_FIRST:
question, answer = answer, question
print(question)
input("> ")
print(f"ANSWER: {answer}\n\n")
except EOFError:
print("\nBye") `
The entirety of the code can be found here: Learning Python The hard way Ex. 41 - Learning to Speak Object-Oriented