Hello,

I'm a new bie to python programming and on the processing of learning python
programming. I have coded my first program of fibonnaci generation and would
like to know if there are better ways of achieving the same.

I still feel quite a few things to be improved. Just wanted experts thoughts
on this.

try:

    length = input('Enter the length till which you want to generate the
fibonnaci series: \n')
    print type(length)

except:
    print 'Invalid input detected'
    exit(0)

if type(length) is int:
    result = []
    a = 0
    b = 1
    result.append(a)
    result.append(b)
    if length > 2:
        count = 2
        while count  < length:
            c = a + b
            a = b
            b = c
            result.append(c)
            count += 1
        else:
            print result
            print 'The lenght of result is : ' , len(result)
    else:
        print 'Fibonacci series could not be generated !!!'
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to