import csv
def loadQuestions():
Question_List = []
Answer_List = []
with open('Questions.csv', 'r') as myfile:
reader = csv.reader(myfile)
for row in reader:
if row != ['Question', 'Answer']:
Question_List.append(row[0])
Answer_List.append(row[1])
return Question_List, Answer_List
def main():
print('Welcome to my Bio Quiz! You are given the question and a possible answer or a true or false statment.')
while True:
print('Access granted!\nYou can now access the quiz\n')
Questions, Answers = loadQuestions()
print('\nQuiz starting now!')
score = Questions(Answers, Questions)
答案 0 :(得分:0)
Questions, Answers = loadQuestions()
在loadQuestions函数调用上方,将返回两个列表。
score = Questions(Answers, Questions)
现在,您再次对名为Questions
的变量进行函数调用,该变量的类型为loadQuestions()
函数返回的列表(第20行),因此会出现错误。
您必须更改变量Questions
的名称(第20行)或更改希望在score = Questions()
调用的函数的名称(第21行)。