So I need to make a function that sums the squares of the numbers up until n, using only a return.
I've tried:
from functools import reduce
def soma_quadrados(n):
return sum(list(reduce(lambda x: x**2, list(range(1,n+1)))))
Which gives the error:lambda () takes 1 positional argument but 2 were given
I've also tried
return sum(list(reduce(lambda x: x**2, n)))
Which gives the error: reduce() arg 2 must support iteration
What should I do? Thanks in advance
reduceat all?