开发者

Why am I receiving these syntax errors in Python 3.1.2?

I have been receiving errors when tryin开发者_JS百科g to save and run this Python 3.1 script, and I'm not sure why. I'm new to python, and I've been trying some of the Project Euler problems (this is problem 2). I recieve a "invalid syntac" error on "evenfibsum(v)", and on the colon after "_____main_____". I'm not sure why this is as I wrote a script for the first Project Euler problem in this same fashion, and it worked fine. I understand that I could write a script without defining a function, but I'm still interested in why this is not working.

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()


There is no closing bracket in v = int(...


You are missing a closing parenthesis on the line assigning v.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜