kumar s wrote:
Problem: How do i capture every alternative element in list a:
I am unable to pump the a,b, and c into keys list and apple, boy,cat into vals list.
In a sufficiently recent version of Python, you should be able to use an extended slice with a stride --
keys = a[::2]
vals = a[1::2](Note that this is untested, as I don't have a recent version of Python handy at the moment; I'm on 2.2 here, which doesn't have extended slices.)
Jeff Shannon Technician/Programmer Credit International
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
