Why is a None appearing in my output?

Hornberger, Chris Chris.Hornberger at blackrock.com
Wed May 12 16:04:12 EDT 2004


Yeah, I've recently found the Python religion myself. Loving it.

--------------------------
Chris Hornberger
Blackrock - 302.797.2318
chris.hornberger at blackrock.com

Card carrying MSDN member since 2004.
No, really. I've got the card to prove it.


-----Original Message-----
From: David Stockwell [mailto:winexpert at hotmail.com]
Sent: Wednesday, May 12, 2004 4:00 PM
To: Hornberger, Chris
Cc: python-list at python.org
Subject: RE: Why is a None appearing in my output?


Thanks,

I didn't see that.  I'm a c/c++ programmer for the most part and this is my 
2nd day at python...




>From: "Hornberger, Chris" <Chris.Hornberger at blackrock.com>
>To: "David Stockwell" <winexpert at hotmail.com>, <python-list at python.org>
>Subject: RE: Why is a None appearing in my output?
>Date: Wed, 12 May 2004 15:50:14 -0400
>
>You're not returning a value, simply holding it or printing stuff out. 
>Return your value inside the function call. Thusly:
>
>def SomeFunction( someVar ):
>	returnVal = 0
>	# do stuff
>	return returnVal
>
>
>
>--------------------------
>Chris Hornberger
>Blackrock - 302.797.2318
>chris.hornberger at blackrock.com
>
>Card carrying MSDN member since 2004.
>No, really. I've got the card to prove it.
>
>
>-----Original Message-----
>From: python-list-bounces+chris.hornberger=blackrock.com at python.org
>[mailto:python-list-bounces+chris.hornberger=blackrock.com at python.org]On
>Behalf Of David Stockwell
>Sent: Wednesday, May 12, 2004 3:47 PM
>To: python-list at python.org
>Subject: Why is a None appearing in my output?
>
>
>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
>
>
>--
>http://mail.python.org/mailman/listinfo/python-list

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee® 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963





More information about the Python-list mailing list