tags:

views:

72

answers:

2

I have been receiving errors when trying 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()
+11  A: 

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

gruszczy
Thanks for pointing out my mistake!
FlowofSoul
A: 

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

Matthew Rankin