Math, asked by suryasiddhu1033, 1 year ago

Do not use `len(sequence)` to determine if a sequence is empty (len-as-condition)

Answers

Answered by Anonymous
2

doesn't know the context in which it is called, so if computing the length means traversing the entire sequence, it must; it doesn't know that the result is just being compared to 0. Computing the boolean value can stop after it sees the first element, regardless of how long the sequence actually is. I think pylint is being a tad opinionated here, though; I can't think of any situation where it is wrong to use len, just that it's a worse option than the alternative

I hope this will help you

If helpful then please select my answer as brainliest answer

And also follow me ❤️❤️❤️❤️❤️❤️❤️

Similar questions