You are slicing a string!
A slice operation starts with index 0
In python a slice operation is of format [start:stop:step]
Keep a example string as MyString = "Hi MoPaMo"
Here the first letter has the index as 0
Hi MoPaMo
012345678
So print(MyString[0:4]) is going to output the 1st 4 index numbers
Hi M
0123
From Index 0 to index 4
a="0123456789"
So in a[:] you are telling there is no start or stop, print everything
In print(a[1:]) you are telling start from index 1
In print(a[:5]) you are telling stop at index 5, therefore it prints 01234
In print(a[1:5]) you are telling to start at index 1 and stop at index 5 which results in 1234
print(a[1:8:2]) is going to print 1357
Here you are telling to skip alternate elements
Do check out this doc Pythons String Doc