我正在学习 python 并且正在研究这个问题,但似乎无法让它发挥作用。执行此代码时,我在不同的行上得到数字 1 到 8。我怎样才能只打印 8 的计数?
honor_roll_count = 0
student_grades = ["A", "C", "B", "B", "C", "A", "F", "B", "B", "B", "C", "A"]
for grade in student_grades:
if grade in "AB":
honor_roll_count = honor_roll_count + 1
print honor_roll_count