Class code works in Python 2 & 3 with unicode (I think).

This commit is contained in:
Jonathan Harker 2014-11-24 17:20:32 +13:00
parent 52538dc5a6
commit ebc7deb572

12
quiz.py
View file

@ -1,7 +1,7 @@
#!/usr/bin/env python
## -*- coding: utf-8 -*-
import sys
if sys.version_info[0] < 3:
raise RuntimeError("Python 3 required.")
from __future__ import unicode_literals, print_function
from io import open
class Question:
@ -168,11 +168,13 @@ class QuestionBank:
return questions
# A crappy test.
if __name__ == '__main__':
qb = QuestionBank('/home/johnno/questions.doctorlard.en')
qb = QuestionBank('questions.doctorlard.en')
for q in qb.questions:
print(q.question)
a = input('A: ')
a = unicode(raw_input('A: '), 'utf8')
#a = input('A: ') # Python 3
if a.lower() == q.answer.lower():
print("Correct!")
else: