Jabin Jezreel wrote:
What is the idiomatic way to write the right side of
    (a, b) = (l[0:2], l[2:])
?
(not worried about the parens, just the splitting of the sequence)

------------------------------------------------------------------------

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
What you are doing is already fine although you can drop the starting index for the first slice

>>> l=[1,2,3,4,5,6,7,8,9,10]
>>> l[:2], l[2:]
([1, 2], [3, 4, 5, 6, 7, 8, 9, 10])

--
Kind Regards,
Christian Witts


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to