Why is a None appearing in my output?

David Stockwell winexpert at hotmail.com
Wed May 12 15:46:59 EDT 2004


Hello,

I'm a fairly new user of python.  I am going through the
tutorial on the python.org website and observed a weird thing
around the 6.0 modules area.  (http://docs.python.org/tut/node8.html)

My python version:
Python 2.2.3 (#1, Feb 26 2004, 14:37:42)
[GCC 3.2 20020903 (Red Hat Linux 8.0 3.2-7)] on linux2


I entered the following text into a 'module file' and saved it:

def fib6(n):    # write Fibonacci series up to n
    a, b = 0, 1
    while b < n:
        print  b,
        a, b = b, a+b
    else:
        print "done b[",b,"], n[",n,"], a[", a,"]"

print "fib6:", fib6(50), "---"
print "next"


I then run it and get the results:
fib6: 1 1 2 3 5 8 13 21 34 done b[ 55 ], n[ 50 ], a[ 34 ]
None ---
next

The question I'm having is what is causing the 'None' to print?
The example tutorial doesn't have the None, but when I run
I am seeing it and I do not see what causes that.

I added the 'else on the while and the "---" stuff to try to figure out what 
the None means.

but i have no clue ...

Thanks

David

_________________________________________________________________
Getting married? Find tips, tools and the latest trends at MSN Life Events. 
http://lifeevents.msn.com/category.aspx?cid=married





More information about the Python-list mailing list