Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Commit b2fd950

Browse files
committed
questions: make answer comparison smarter
use casefold() instead of lower() use strip() on the inbound answer in case someone had a trailing space
1 parent e652d40 commit b2fd950

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

CodeChallenge/api/questions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def answer_next_question():
105105

106106
data = request.get_json()
107107
text = data["text"]
108-
correct = str_cmp(text.lower(), q.answer.lower())
108+
correct = str_cmp(text.casefold().strip(), q.answer.lower())
109109

110110
ans = Answer.query.filter_by(user_id=user.id, question_id=q.id).first()
111111

0 commit comments

Comments
 (0)