The question is:Each new term in the Fibonacci sequence is generated by adding the previous two terms.    By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...  By considering the terms in the Fibonacci sequence whose values do not exceed four   million, find the sum of the even-valued terms.#Problem 2P2 = 0fib= 0f1 = 1f2 = 0debugP2 = []while fib < 4000000:    fib = f1 + f2    f2 = f1    f1 = fib    if fib % 2 == 0:        P2 += fib        debugP2.append(fib)print(debugP2)print(P2)This script canGive me all Fibonacci numbers up to 4000000 Give the sum of all even numbers up to 4000000It satisfies Project Euler Question #2.Is there a way to make this shorter or more efficient?
Project Euler Question #2: Sum of even Fibonacci numbers under 4 million
python;project euler;fibonacci sequence