breaking a loop
el chupacabra
nowayjose at noway.com
Thu Aug 11 15:44:11 EDT 2005
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