Force answers to be provided as strings

This commit is contained in:
John Donaldson 2019-07-09 18:59:57 +01:00 committed by Neale Pickett
parent ffab4d37b6
commit 97f808804e
1 changed files with 4 additions and 1 deletions

View File

@ -143,10 +143,13 @@ class Puzzle:
elif key == 'summary':
self.summary = val
elif key == 'answer':
if not isinstance(val, str):
raise ValueError("Answers must be strings, got %s, instead" % (type(val),))
self.answers.append(val)
elif key == "answers":
for answer in val:
answer = str(answer)
if not isinstance(answer, str):
raise ValueError("Answers must be strings, got %s, instead" % (type(answer),))
self.answers.append(answer)
elif key == 'pattern':
self.pattern = val