L = [....] while L: if match(L[0], key): break else: L = L[1:] else: print 'no match...' def func(): ...