[Tutor] while with function
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Sun Nov 17 14:39:01 2002
On Sat, 16 Nov 2002 fleet@teachout.org wrote:
> Sigh. If one enters a non-zero number first, the tries again WITHOUT
> reinitializing y, it fails (because y no longer equals 0). (Where's the
> lid to my hole?!)
Hi Fleet,
> > > 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.
By the way, here's another way to write your loop:
###
while 1:
y = getnum()
print y
if y: break
###
Good luck!