M.E.Farmer wrote:
Hello Ishwor ,
The simpliest way I can explain slicing is that the slices point to the
spot *between* the items......
Take this list for example
slicer = [0,1,2,3,4,5]
slicer [1]
1
slicer [1:2]
[1]
slicer [:-1]
[0,1,2,3,4]
slicer[2,4]
[2,3]
You can also use a "stride" rather than take every element and (in
recent Pythons) go backwards:
Python 2.4 (#1, Dec 4 2004, 20:10:33)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> slicer = [0,1,2,3,4]
>>> slicer[::2]
[0, 2, 4]
>>> slicer[1::2]
[1, 3]
>>> >>> slicer[::-1]
[4, 3, 2, 1, 0]
>>> slicer[-1::-2]
[4, 2, 0]
>>>
regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list