为什么我在Python 3.1.2中收到这些语法错误?

0 python

我在尝试保存并运行这个Python 3.1脚本时遇到了错误,我不知道为什么.我是python的新手,我一直在尝试一些Project Euler问题(这是问题2).我在"evenfibsum(v)"和"_____main_____"之后的冒号上收到"无效的syntac"错误.我不知道为什么这是因为我以同样的方式为第一个Project Euler问题编写了一个脚本,并且它运行良好.我知道我可以在不定义函数的情况下编写脚本,但我仍然对为什么这不起作用感兴趣.

def evenfibsum(v):
    a = 1
    b = 2
    r = 0
    while b < v:
        if b%2 == 0:
            r = r + b
            a, b = b, a+b
        else:
            a,b = b, a+b

    print("The sum of the Fibonacci sequence is: ", r)

def main():
    print("This program is designed to find the sum of all even")
    print("numbers from the specificed Fibonacci sequence.")
    v = int(input("What is the highest number you would like to evaluate in the sequence? ")

    evenfibsum(v)

if __name__ == '__main__':
    main()
Run Code Online (Sandbox Code Playgroud)

gru*_*czy 11

没有关闭括号v = int(...