I donä't get while-loops
Larry Bates
larry.bates at websafe.com`
Sat Aug 2 16:18:01 EDT 2008
ssecorp wrote:
> in read2 it never quits when I write quit, why?
>
> def read():
> expr = raw_input("Lisp> ")
> if expr != "quit":
> print parse(expr)
> read()
> else:
> print "Good session!"
>
> def read2():
> expr = ""
> while expr != "quit":
> expr = raw_input("Lisp> ")
> print parse(expr)
> read2()
> print "Good session!"
That's because read2() is being called recursively making expr be always a blank
string the first time you go through the loop. Delete the call to read2() that
is inside your while loop and try.
-Larry
More information about the Python-list
mailing list