Class code works in Python 2 & 3 with unicode (I think).
This commit is contained in:
parent
52538dc5a6
commit
ebc7deb572
1 changed files with 7 additions and 5 deletions
12
quiz.py
12
quiz.py
|
|
@ -1,7 +1,7 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
## -*- coding: utf-8 -*-
|
## -*- coding: utf-8 -*-
|
||||||
import sys
|
from __future__ import unicode_literals, print_function
|
||||||
if sys.version_info[0] < 3:
|
from io import open
|
||||||
raise RuntimeError("Python 3 required.")
|
|
||||||
|
|
||||||
|
|
||||||
class Question:
|
class Question:
|
||||||
|
|
@ -168,11 +168,13 @@ class QuestionBank:
|
||||||
return questions
|
return questions
|
||||||
|
|
||||||
|
|
||||||
|
# A crappy test.
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
qb = QuestionBank('/home/johnno/questions.doctorlard.en')
|
qb = QuestionBank('questions.doctorlard.en')
|
||||||
for q in qb.questions:
|
for q in qb.questions:
|
||||||
print(q.question)
|
print(q.question)
|
||||||
a = input('A: ')
|
a = unicode(raw_input('A: '), 'utf8')
|
||||||
|
#a = input('A: ') # Python 3
|
||||||
if a.lower() == q.answer.lower():
|
if a.lower() == q.answer.lower():
|
||||||
print("Correct!")
|
print("Correct!")
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue