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

相关文章:

  • 2021-12-04
  • 2021-11-17
  • 2021-12-08
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-28
  • 2021-11-23
  • 2021-12-04
  • 2022-12-23
  • 2021-10-01
  • 2021-12-20
  • 2021-04-24
相关资源
相似解决方案