I have learned in class that for Python, characters stars from [0]. For example in Monty Python, 'M'=0, 'o'=1, 'n'=2, 't'=3, 'y'=4, ' '=5, 'P'=6, 'y' = 7, 't' = 8, 'h'=9, 'o' = 10, and 'n' = 11.
But I am confused when I saw the following operation on NLTK:
genre_word = [(genre, word) for genre in ['news', 'romance']
for word in brown.words(categories=genre)]
genre_word[:4]
genre_word[-4:]
I thought all character numbering starts with [0]
. What does the [-4:]
means?