I have a list of many elements.
I care about two of its elements, a
and b
.
I don't know the order of the list, nor do I want to sort it.
Is there a nice one-liner that will return True
if a
occurs before b
and false otherwise?
In the interests of diversity, you could also:
b in l[l.index(a):]
This will be True
if a == b
. If you know that a != b
,
b in l[l.index(a) + 1:]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With