Python: slicing a multi-dimensional array
If you use numpy, this is easy: or if you want the 0’s, You’ll get the same result. *note that slice is actually the name of a builtin-type. Generally, I would advise giving your object a different “name”. Another way, if you’re working with lists of lists*: (Note that the 0’s here are unnecessary: [arr[i][:2] for i in range(2)] would … Read more