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 -*-
|
||||
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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue