How does slice notation in Python work?

0 votes
Can someone help me with the 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 31, 2018 in Python by findingbugs
• 3,140 points
28 views

1 answer to this question.

0 votes

The Python tutorial talks about it (scroll down a bit until you get to the part about slicing).

The ASCII art diagram will help you get a clear idea on how does this notation work:

 +---+---+---+---+---+---+
 | P | y | t | h | o | n |
 +---+---+---+---+---+---+
 0   1   2   3   4   5   6
-6  -5  -4  -3  -2  -1
answered Oct 31, 2018 by Priyaj
• 56,160 points

Related Questions In Python

0 votes
1 answer

How does insertion work in Python?

Or, this one: def ins_sort(k): ...READ MORE

answered Oct 8, 2018 in Python by charlie_brown
• 7,710 points
21 views
0 votes
1 answer

How does % work in Python?

The % (modulo) operator yields the remainder ...READ MORE

answered Oct 10, 2018 in Python by SDeb
• 12,280 points
16 views
0 votes
0 answers

How does function definition work in python?

Is it same as other programming languages ...READ MORE

Jun 13 in Python by Waseem
• 3,440 points
9 views
0 votes
0 answers

How does pillow work in opening and closing images in python?

Is there a separate library that we ...READ MORE

2 days ago in Python by Waseem
• 3,440 points
8 views
0 votes
1 answer

Understanding Python's slice notation

It's pretty simple really: a[start:end] # items start ...READ MORE

answered Oct 25, 2018 in Python by SDeb
• 12,280 points
53 views
+1 vote
2 answers

how can i count the items in a list?

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

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 127 views
+1 vote
1 answer

Why does x,y = zip(*zip(a,b)) work in Python?

I'm extremely new to Python so this ...READ MORE

answered Aug 23, 2018 in Python by Priyaj
• 56,160 points
38 views
+2 votes
3 answers

How can I play an audio file in the background using Python?

down voteacceptedFor windows: you could use  winsound.SND_ASYNC to play them ...READ MORE

answered Apr 3, 2018 in Python by charlie_brown
• 7,710 points
1,310 views