pythonpython-2.7listpython-3.x

How to get everything from the list except the first element using list slicing


I want to parse something like:

list = ['A', 'B', 'C']

And using list slicing have it return to me everything but the first index:

['B', 'C']

I tried list[:-1], list[::-1], list[0:-1], etc.

What I am doing:

If answer differs via Python 2.7.x and Python 3.x.x, please answer for both versions.


Solution

  • You can just do [1:]. This will work on both versions.