else
clause as well, which is not really well-known). You can also use
next(x for x in lst if ...)
which will return the first match or raise a StopIteration
if none is found. Alternatively, you can use
next((x for x in lst if ...), [default value])
Source: http://stackoverflow.com/questions/9542738/python-find-in-list
Žádné komentáře:
Okomentovat