实现可多样化,这样居然不让通过
d = { 'Adam': 90, 'Lisa': 55, 'Bart': 59 }
def generate_tr(name, score):
if score < 60:
score = '<font color="red">%s</font>' % score
return '<tr><td>%s</td><td>%s</td></tr>' % (name, score)
tds = [generate_tr(name,score) for name, score in d.iteritems()]
print '<table border="1">'
print '<tr><th>Name</th><th>Score</th><tr>'
print '\n'.join(tds)
print '</table>'
#可以在generate_rt()函数里判断score然后重新赋值score