breaking a loop

infidel saint.infidel at
Thu Aug 11 22:32:28 CEST 2005

> Desired behavior: when I type 'exit' the program should quit.

def search():
    user_input = ''
    while True:
        user_input = raw_input('Search for: ')
        if user_input == 'exit': break
        print 'processing', user_input

Note that putting user input directly into SQL statements leaves your
database open to SQL-injection attacks :-)

More information about the Python-list mailing list