标签: python function
用户跳过前两个元素来总结整个给定列表 例如:sum_of_marks(['ali','P176133',45,32,90,87)它应该返回数字的总和
sum_of_marks(['ali','P176133',45,32,90,87)
答案 0 :(得分:1)
您可以使用和函数
def sum_of_marks(lst): lst=['ali','P176133',45,32,90,87] return sum(lst[2:]) print sum_of_marks(['ali','P176133',45,32,90,87])