python代码 运行报错

代码 和报错 部分 如图中所示 求大神指点

import random 

amino_acid={'Alanine':'Ala','Valine':'Val','Leucine':'Leu','Isoleucine':'Ile','Phenylalanine':'Phe','Tryptophane':'Trp','Mrthionine':'Met','Proline':'Pro','Glycine':'Gly','Serine':'Ser','Threinine':'Thr','Cysteine':'Cys','Tyrosine':'Tyr','Asparagine':'Asn','Glutamine':'Gln','Histidine':'His','Lysine':'Lys','Argine':'Arg','Aspartic acid':'Asp','Glutamic acid':'Glu'}
#generate 35 quiz files.
for i in range(35):
    #create the quiz and answer key files.
    quiz_file=open('quiz%s.txt'%(i+1),'w')
    answerkey_file=open('quiz_answer%s.txt'%(i+1),'w')
    #write out the header for the quiz.
    quiz_file.write('Name:\n\nDate:\n\nPeriod:\n\n')
    quiz_file.write((' '*20)+'Amino acids quiz (Form %s)'%(i+1))
    quiz_file.write('\n\n')
    #shuffle the order of the states.
    quancheng=list(amino_acid.keys())
    random.shuffle(quancheng)
    #loop through all 20 amino acids, making a questions for each.
    for j in range(20):
        #get right and wrong answers.
        correct_answer=amino_acid[quancheng[j]]
        wrong_answer=list(amino_acid.values())
        del wrong_answer[wrong_answer.index(correct_answer)]
        answer_options=wrong_answer+[correct_answer]
        random.shuffle(answer_options)
        #write the question and the answer options to the quiz file.
        quiz_file.write('%s.What is the fullname of %s\n'%(j+1,quancheng[j]))
        for k in range(4):
            quiz_file.write(' %s. %s\n'%('ABCD'[k],answer_options[k])
        #write a answer key to a file.
        answerkey_file.write('%s. %s\n'%(j+1,'ABCD'[answer_options.index(correct_answer)]))
    quiz_file.close()
    answerkey_file.close()

 

quiz_file.write(' %s. %s\n' % ('ABCD'[k], answer_options[k]) 这句少了一个)符号修改如下:
quiz_file.write(' %s. %s\n' % ('ABCD'[k], answer_options[k]))

更多Python知识请参考

http://www.xinbiancheng.cn/python3/