question_data = [
{"text": "A slug's blood is green.", "answer": "True"},
{"text": "The loudest animal is the African Elephant.", "answer": "False"},
{"text": "Approximately one quarter of human bones are in the feet.", "answer": "True"},
{"text": "The total surface area of a human lungs is the size of a football pitch.", "answer": "True"},
{"text": "In West Virginia, USA, if you accidentally hit an animal with your car, you are free to take it home to eat.",
"answer": "True"},
{"text": "In London, UK, if you happen to die in the House of Parliament, you are entitled to a state funeral.",
"answer": "False"},
{"text": "It is illegal to pee in the Ocean in Portugal.", "answer": "True"},
{"text": "You can lead a cow down stairs but not up stairs.", "answer": "False"},
{"text": "Google was originally called 'Backrub'.", "answer": "True"},
{"text": "Buzz Aldrin's mother's maiden name was 'Moon'.", "answer": "True"},
{"text": "No piece of square dry paper can be folded in half more than 7 times.", "answer": "False"},
{"text": "A few ounces of chocolate can to kill a small dog.", "answer": "True"}
]
我还有一个问题课:
class Question:
def __init__(self, text, answer):
self.question_text = text
self.question_answer = answer
这是我的代码:
from question_model import Question
from data import question_data
question_bank = []
for question in question_data():
q_text = question["text"]
q_answer = question["answer"]
new_q = Question(q_text, q_answer)
print(new_q)
question_bank.append(new_q)
print(question_bank)
每当我运行代码时,它都会给出错误:
for question in question_data():
TypeError: 'list' object is not callable