在单独的行上打印列表项

时间:2015-05-06 16:30:57

标签: python-2.7

我正在尝试打印每个等级的成绩列表,这是我到目前为止所拥有的

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def print_grades(grades):  

    for grade in grades:  

       print grade  

2 个答案:

答案 0 :(得分:0)

如果您尝试

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

for grade in grades:  

    print grade

它应该做你想要的。我对原始片段的唯一顾虑是你实际上没有调用你定义的函数。相反,试试这个

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def print_grades(grades):
    for grade in grades:
        print grade

if __name__ == '__main__':
    print_grades(grades)

答案 1 :(得分:0)

尝试使用此

breakdownDenominations($amount,$denominations)