Table of Contents
link:snippets.py[role=include]see code at snippets.py
— from: stackoverflow
finding first
next((x for x in range(10) if x > 3), 'not found')
# will return 4will return the first number from 0 to 10 above 3, ie 4.
not finding
next((x for x in range(10) if x > 10), 'not found')
# will return 'not found'there is no number above 10 in range(10), returns "not found" in that case.
see path
local |
global |
attribute of an object |
|
|
|