解决方式:*表达式
grades = [56,45,26,89,35,98,54,39,54,80,54,62,61,60,97,95,90,61,37,65]
def drop_first_last(grades):
first,*middle,last = grades
return avg(middle)
def avg(grades):
return sum(grades)/len(grades)
print(drop_first_last(grades))
输出:
63.166666666666664