Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.
Prev Previous commit
Next Next commit
questions: make answer comparison smarter
use casefold() instead of lower() use strip() on the inbound answer in case someone had a trailing space
  • Loading branch information
usrbinsam committed Apr 8, 2020
commit b2fd9503c213ce7f06ba0dca091e974b43371409
2 changes: 1 addition & 1 deletion CodeChallenge/api/questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def answer_next_question():

data = request.get_json()
text = data["text"]
correct = str_cmp(text.lower(), q.answer.lower())
correct = str_cmp(text.casefold().strip(), q.answer.lower())

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

Expand Down