I am wanting to find the resource doc on “slicing” for python (i.e. “:”) but I can’t seem to find it. It isn’t under Docs/Python/List. Anyone know where I can find the resource doc for slicing in python on codecademy? Thanks!
Maybe what you’re looking for?
While not aware of any such resource, the process of slicing is very simple and straight forward, and sharing the STOP value property with
range(start (inclusive), stop (exclusive), step) print (list(range(1, 11, 2))) # [ 1, 3, 5, 7, 9 ]
Notice there is no
11 in that sequence?
alist[start (inclusive) : stop (exclusive) : step] alist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11][0:10:2] print (alist) # [ 1, 3, 5, 7, 9 ]
Ping this topic if you wish to go into greater detail on such things as optional parameters, reversing and so on.
Here are a few other examples of slicing:
Perfect , thank you so much.
Thank you for helping
Thank you for taking the time to help