Hi Apologies if I am being naïve but in https://docs.python.org/3/tutorial/introduction.html#lists Is the 5 in
# now remove them
letters[2:5] = []
letters
['a', 'b', 'f', 'g'] deliberate as it only replaces 3 not 4 letters. Regards Simon
Hey Simon, On Fri, Jul 1, 2022, at 11:19 AM, sgbrock@gmail.com wrote:
Hi
Apologies if I am being naïve but in https://docs.python.org/3/tutorial/introduction.html#lists
Is the “5” in *>>> **# now remove them* *>>> *letters[2:5] = [] *>>> *letters ['a', 'b', 'f', 'g']
deliberate as it only replaces 3 not 4 letters.
I'm unsure what you mean. The 5 seems to be deliberate as the slice syntax is [start:stop:step], so in this case it means 'replace things from 2 to 5' (e.g. indices 2, 3, and 4).
Regards Simon _______________________________________________ docs mailing list -- docs@python.org To unsubscribe send an email to docs-leave@python.org https://mail.python.org/mailman3/lists/docs.python.org/ Member address: cmdr@supakeen.com
participants (2)
-
sgbrock@gmail.com
-
Simon de Vlieger