Instructions
Complete the square sum function so that it squares each number passed into it and then sums the results together.
For example, for[1, 2, 2]
it should return 9
because 1^2 + 2^2 +2^2 = 9
Solution
def square_sum(numbers):
return sum(value**2 for value in numbers)
标签:Square,return,Sum,value,square,numbers,sum From: https://www.cnblogs.com/artwalker/p/17210529.html使用列表解析使得代码更加简洁