Skip to content

Commit

Permalink
Use regex for keeping the ?
Browse files Browse the repository at this point in the history
  • Loading branch information
filias committed Nov 20, 2023
1 parent 8566fae commit 2ffa18f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mango/mango/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

import requests
from django.views.generic import TemplateView

Expand All @@ -14,8 +16,8 @@ def get_joke():
return get_joke()

# split the joke into question and answer
question, answer = joke.split("?")
return f"{question}?", answer
question, answer = re.split(r'(?<=\?)', joke)
return question, answer


class IndexView(TemplateView):
Expand Down

0 comments on commit 2ffa18f

Please sign in to comment.