I think u need break before exit() so if u want break from any loop just add break
"el chupacabra" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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/ =- > -- http://mail.python.org/mailman/listinfo/python-list