Oct-01-2020, 02:06 AM
(This post was last modified: Oct-01-2020, 02:07 AM by naughtysensei.)
Inserting items with non-negative index gives expected results:
num = [1, 2, 3] num.insert(0, "min") print(num)
Output:['min', 1, 2, 3]
but with negative index, as in this case shouldn't "max" be inserted at last indexnum.insert(-1, "max") print(num)
Output:['min', 1, 2, 'max', 3]
I mean its not wrong its how they made python to work but why would they do so or am being stupid here?