Y
Y
YraganTron2014-01-03 17:27:30
Python
YraganTron, 2014-01-03 17:27:30

How to get a slice in Python to the right?

I recently started learning python and got to slices. Given a list.
1 2 3 4 5
From it we get
2 3 4 5 0
That's how
a = a[1:] + [0]
And how to get it?
0 1 2 3 4

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Nikitenko, 2014-01-03
@YraganTron

Well, for example like this:
[0] + a[:-1]

A
Andrey Belov, 2014-01-03
@Andrey_Belov

If no cuts:
[i-1 for i in a]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question