0 votes
I need a good explanation on Python's slice notation.

To me, this notation needs a bit of picking up.

It looks extremely powerful, but I haven't quite got my head around it.
Oct 25, 2018 in Python 624 views

## 1 answer to this question.

0 votes
It's pretty simple really:

a[start:end] # items start through end-1
a[start:]    # items start through the rest of the array
a[:end]      # items from the beginning through end-1
a[:]         # a copy of the whole array
There is also the step value, which can be used with any of the above:

a[start:end:step] # start through not past end, by step
The key point to remember is that the :end value represents the first value that is not in the selected slice. So, the difference beween end and start is the number of elements selected.
answered Oct 25, 2018 by
• 13,300 points

0 votes
1 answer

## Understanding slice notation

To answer your question let me explain ...READ MORE

0 votes
1 answer

## Slice notation in Python for string reversal

The slice notation is [start:end:step]. Step = ...READ MORE

+4 votes
8 answers

## How can I use Python's range function?

The range function is mostly used in for-loop.  Ex: for ...READ MORE

0 votes
1 answer

## How to slice an array using python numpy? Is there any numpy tutorial which has covered all its operations?

Slicing is basically extracting particular set of ...READ MORE

0 votes
1 answer

## How does slice notation in Python work?

The Python tutorial talks about it (scroll down a ...READ MORE

0 votes
1 answer

## how do i change string to a list?

suppose you have a string with a ...READ MORE

0 votes
2 answers

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote
2 answers

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

0 votes
1 answer

## Does Python's time.time() return the local or UTC timestamp?

The time.time() function returns the number of seconds since ...READ MORE

0 votes
1 answer

## Understanding generators in Python

A generator is simply a function which ...READ MORE