Tim Peters added the comment:

It's fine.  Read the docs.  "s.insert(i, x) inserts x into s at the index given 
by i (same as s[i:i] = [x])"

Note that:

>>> fred[-1:]
[4]

So the empty slice s[-1:-1] is _between_ 3 and 4 in `fred`.  If you're not 
surprised by

>>> fred[-1]
4

then you shouldn't be surprised by what `fred.insert(-1, whatever)` does either 
;-)

----------
nosy: +tim.peters
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28423>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to