def test_fib_generator(): """Tests fib generator output """ for index, number in fibonacci_generator(): #: since the generator is infinite, we'd like to terminate at some #: point if index >= len(FIBONACCI_NUMBERS): break assert number == FIBONACCI_NUMBERS[index]
def problem_2(): """ Attempt to solve the problem... """ total = 0 for value in fibonacci_generator(): if value[1] >= 4000000: break if value[1] % 2 == 0: total += value[1] return total