breaking a loop
Mosti El
ebouabyd at welho.com
Sat Aug 13 05:21:12 EDT 2005
I think u need break before exit()
so if u want break from any loop just add break
"el chupacabra" <nowayjose at noway.com> wrote in message
news:fUNKe.5188$5g.4209 at tornado.socal.rr.com...
> Hi, I'm just learning Python....thanks in advance...
>
> Do you get out of this loop?
>
> Problem: When I type 'exit' (no quotes) the program doesn't quit the
loop...it actually attemps to find entries that containt the 'exit' string.
>
> Desired behavior: when I type 'exit' the program should quit.
>
> def search():
> searchWhat = ""
> while searchWhat != 'exit':
> searchWhat = "%%%s%%" % raw_input ('Search for : ')
> cursor.execute("select * from TABLE where FIELD like %s",
(searchWhat))
> result = cursor.fetchall()
> print
'+------------------------------------------------------------------+'
> print '| # | Name |
LastName |'
> print
'+------------------------------------------------------------------+'
> for record in result:
> print ' ', record[0], ' : ', record[1], ' ==> ',
record[2]
> print
'+------------------------------------------------------------------+'
> #end for statement, end of search
>
>
> --------------= Posted using GrabIt =----------------
> ------= Binary Usenet downloading made easy =---------
> -= Get GrabIt for free from http://www.shemes.com/ =-
>
More information about the Python-list
mailing list