Skip to content
Advertisement

Not able to print simple fibonacci series in python?

Trying to print simple fibonacci series in Komodo using Python.

but not getting any o/p

Can someone explain me the mistake.

I’m starting to learn Python. please let me know from where to start. Any link to full python course.

#!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/

# simple fibonacci series
# the sum of two elements defines the next set
def feb(a,b):
    a, b = 0, 1
    while b < 1000:
        print(b, end = ' ', flush = True)
    a, b = b, a + b
    print()

Advertisement

Answer

you didn’t call your function. Just call it and also remove parameters as you already assigned them inside your body.

make following changes in your code

def feb():
    a, b = 0, 1
    while b < 1000:
        print(b, end = ' ', flush = True)
    a, b = b, a + b
feb() 
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement