split by index python code example
Example: python split at index
>>> list1 = ['a','b','c','d','e','f','g','h', 'i', 'j', 'k', 'l']
>>> print list1[:5]
['a', 'b', 'c', 'd', 'e']
>>> print list1[-7:]
['f', 'g', 'h', 'i', 'j', 'k', 'l']
# Note how you can slice either positively or negatively.
# When you use a negative number, it means we slice from right to left.