(Apr-21-2019, 04:17 AM)DJ_Qu Wrote: Why not inserting at -2, that is the second to last? I spent quite a while thinking about it, I can't figure out why the negative index needs to be -1.
When in doubt, it's always good to start with built-in help:
>>> help(list.insert) Help on method_descriptor: insert(self, index, object, /) Insert object before index. (END)I think that this is quite straightforward explanation.
Why is it so? Try to answer the question: how to insert something before first element which happens to have index 0? There is no index that can represent that position... This ain't replace method which replaces element on specific index.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.