On Fri, Jan 15, 2016 at 10:53 PM, Cameron Simpson <c...@zip.com.au> wrote:
> On 15Jan2016 22:20, boB Stepp <robertvst...@gmail.com> wrote:

>> I always get an empty list, which is actually what I was expecting, so
>> I do not see how s[i:i] can ever equal [x].
>
>
> It isn't an equality test (==), it is an assignent. It is saying "set the
> zero length sequence at index i to the one element sequence [x]".

Ah!  That makes sense.


>>>>> things.insert(-1, 'What the heck?!?')
>>>>> things
>>
>> [0, 'Hmm...', 3, 'WhackABunny', 6, 'What the heck?!?', '?']
>>
>> "...at the index..." to me would mean that 'What the heck?!?' should
>> become the last item in the list.  Again, the interpreter help gave
>> what I was expecting.
>
>
> To me it means "insert 'x' so that its index is 'i'".

But that's my point!  In my example x (here 'What the heck?!?') is
*not* at index i (here, -1).  Instead it winds up at index -2.  But
this fits in perfectly with the interpreter help, since it winds up
*before* index i (-1).

-- 
boB
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to