Re: [Tutor] list.insert()

2010-01-06 Thread Alan Gauld
"spir" wrote s = [1,2,3,4,5,6,7,8,9] print s, s[-3], s[-4] # [1, 2, 3, 4, 5, 6, 7, 8, 9] 7 6 s.insert(-3, 0) print s, s[-3], s[-4] # [1, 2, 3, 4, 5, 6, 0, 7, 8, 9] 7 0 So, I did insert 0 at index -3, but s[-3] is still 7, & 0 is in fact at index -4. Seems reasonable. insert() inserts befor

Re: [Tutor] list.insert()

2010-01-06 Thread Wayne Werner
On Wed, Jan 6, 2010 at 8:54 AM, spir wrote: > Hello, > > Just found something rather misleading with negative indices: > > s = [1,2,3,4,5,6,7,8,9] > print s, s[-3], s[-4] # [1, 2, 3, 4, 5, 6, 7, 8, 9] 7 6 > s.insert(-3, 0) > print s, s[-3], s[-4] # [1, 2, 3, 4, 5, 6, 0, 7, 8, 9] 7 0 > > So, I

[Tutor] list.insert()

2010-01-06 Thread spir
Hello, Just found something rather misleading with negative indices: s = [1,2,3,4,5,6,7,8,9] print s, s[-3], s[-4] # [1, 2, 3, 4, 5, 6, 7, 8, 9] 7 6 s.insert(-3, 0) print s, s[-3], s[-4] # [1, 2, 3, 4, 5, 6, 0, 7, 8, 9] 7 0 So, I did insert 0 at index -3, but s[-3] is still 7, & 0 is in fact