题目说了没有输入,所以不需要input()因为不知道n的最大值,应该使用while循环,直到1/n小于1e-6,类似这样:
n = 3 s = a = 1 while 1/n >= 1e-6: a *= -1 s += a/n n += 2 print("{0:.6f}".format(s))