python获取一组数个位数之和

pyschools Topic 2: Question 9  题目:给定一组整数,获取其个位数之和

Write a function getSumOfLastDigits() that takes in a list of positive numbers and returns the sum of all the last digits in the list.

def getSumOfLastDigits(numList): 
    return sum(x % 10 for x in numList)
getSumOfLastDigits([1, 23, 456])
Out[11]: 10
原文地址:https://www.cnblogs.com/yongestcat/p/13433577.html