Don't crash with IndexError when we run out of questions
authorW. Trevor King <wking@tremily.us>
Tue, 5 Feb 2013 14:09:50 +0000 (09:09 -0500)
committerW. Trevor King <wking@tremily.us>
Tue, 5 Feb 2013 14:09:50 +0000 (09:09 -0500)
quizzer/ui/__init__.py

index eb8682d7220a52dc1178880bb62922868c649b19..43c1502c74813288cc2b16d7e70821b1444774ed 100644 (file)
@@ -11,7 +11,8 @@ class UserInterface (object):
 
     def get_question(self):
         remaining = [q for q in self.quiz if q not in self.answers]
-        return remaining[0]
+        if remaining:
+            return remaining[0]
 
     def process_answer(self, question, answer):
         if question not in self.answers: