Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Finding Fibonacci series in python using def function

I am beginner in python and and i am trying to find fibonacci series of print the first 10 numbers in the Fibonacci series and i am not getting expected output.

Here is code which i have written:

def fibonacci_with_loop(n):
    fib_series = [0, 1]

    for i in range(2, n):
        next_number = fib_series[-1] + fib_series[-2]
        fib_series.append(next_number)

    print (fib_series)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In order to use the function you wrote, you need to write fibonacci_with_loop() at the end of your code. Could you have forgotten this?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading