python example

Fibonacci sequence in Python

Generate Fibonacci numbers iteratively and print them as a list.

Track two values and append as you go. This stays readable and avoids deep recursion.

If you raise the count too high, the sandbox may time out — start small.

def fibonacci(count):
    values = []
    a, b = 0, 1
    for _ in range(count):
        values.append(a)
        a, b = b, a + b
    return values

print(fibonacci(10))