[Tutor] while with function

fleet@teachout.org fleet@teachout.org
Sat Nov 16 22:48:04 2002


I've written a function getnum()

def getnum()
   x=int(raw_input("get number: ")
   return x

I'm trying to control a while loop as follows:

y=0
while y==0:
   y=getnum()
   print y

No matter what number I enter in response to getnum(), the while loop
prints y then quits.  My assumption is that if the number I enter in
response to getnum() is 0, y should be printed, and getnum() should be
invoked again.  Any number other than 0 should cause the loop to quit.

Where am I going wrong?

				- fleet -