4 ms·
That's a bad idea. If you're not sure whether len() can return -1, and in turn what that value means, then you can't know that your code is any more correct.
by underwater 12y ago
That's a bad idea.
If you're not sure whether len() can return -1, and in turn what that value means, then you can't know that your code is any more correct.
In fact, this is going to be worse than a equals comparison because instead of having code that clearly doesn't handle a corner case you have code that lies about what values it can correctly handle. That makes it much harder to debug.