First, that comma has no place there.
Slicing... Let we have a string.
my_string = 'I feel good.'
So, being a string it has indices. my_string[0] gives us 'I' because in Python the indexing starts at 0 and 'I' is the first character. my_string[-1] gives us the period at the end of the string. The negative index means that we count backward. -1 is 'd', -2 'o' and -4 is 'g'.
The slicing: string[start :stop ]
Starting index is what you are thinking. The slicing starts from there. The stop index means it stops there but it is exclusive.
my_string[0:6] gives us 'I feel'. Well, if you count the characters they are six ( including space ). But we start from 0 so 0 to 5 is exactly 6 characters.
If we need to slice an iterable from the start we can miss the 0 index. Our example becomes my_string[:6] which gives us again 'I feel'. It is the same if we want to slice to the end. my_string[7:] give us 'good'. [:] is the whole string and [2:6] - 'feel'
Slicing... Let we have a string.
my_string = 'I feel good.'
So, being a string it has indices. my_string[0] gives us 'I' because in Python the indexing starts at 0 and 'I' is the first character. my_string[-1] gives us the period at the end of the string. The negative index means that we count backward. -1 is 'd', -2 'o' and -4 is 'g'.
The slicing: string[start :stop ]
Starting index is what you are thinking. The slicing starts from there. The stop index means it stops there but it is exclusive.
my_string[0:6] gives us 'I feel'. Well, if you count the characters they are six ( including space ). But we start from 0 so 0 to 5 is exactly 6 characters.
If we need to slice an iterable from the start we can miss the 0 index. Our example becomes my_string[:6] which gives us again 'I feel'. It is the same if we want to slice to the end. my_string[7:] give us 'good'. [:] is the whole string and [2:6] - 'feel'