Is there a way I could inline this for loop?
already_inserted = True
for i in indexes:
already_inserted = already_inserted and bitfield[i]
already_inserted = all(bitfield[i] for i in indexes)
How about:
already_inserted = all(bitfield[i] for i in indexes)
all() function accepts iterable and will automatically go over all elements and apply bool to each of them. Therefore, it is sufficient to write:
already_inserted = all(bitfield)
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