I need to write a function "sum_reciprocals()" which takes 1 input argument, a positive integer "n", and returns 1 output value, the sum of the reciprocals of all integers from 1 to n (inclusive). The result should be returned as a floating point number, and rounded to 5 decimal places.
here is my code
def sum_reciprocals(n):
x = [1]
n = 10000
for i in range(2,n+1):
x.append(x[i-2]+1/x[i-1])
sum_reciprocals = round(sum(x))
return sum_reciprocals
But it says that "IndexError: list index out of range" on my fifth line.