0

I am new to python and trying to create a function for the sum of squares between 1 and n. I've tried

def squared(x, n):
    tot = sum(x ** 2 for x in range (1, n+1))
    return tot

when I then try to check using

print(squared([1.2, 2.3]))

I get type error

squared() missing 1 required positional argument: 'n'
Tom Karzes
  • 22,815
  • 2
  • 22
  • 41
  • You are missing the second argument `n` of your function. Also, why are you passing `x`? – Dani Mesejo Apr 11 '20 at 14:50
  • Your function expects two arguments, a list `x` and a count `n`. But it doesn't use the values of `x` at all. All it uses is `n`, so change it to expect a single number as its sole argument. The values in the list serve no purpose. – Tom Karzes Apr 11 '20 at 14:53

0 Answers0