thefirst = (i[i for i in range(10) if i > 3)[0]3][0]
If youre not sure that any element will be valid according to the criteria, you should enclose this with try/except since that [0] can raise an IndexError.
Oneliner:
thefirst = (i for i in range(10) if i > 3)[0]
If youre not sure that any element will be valid according to the criteria, you should enclose this with try/except since that [0] can raise an IndexError.
Oneliner:
thefirst = [i for i in range(10) if i > 3][0]
If youre not sure that any element will be valid according to the criteria, you should enclose this with try/except since that [0] can raise an IndexError.
If youre not sure that any element will be valid according to the criteria, you should enclose this with try/except since that [0] can raise an IndexError.