Hello and welcome!
It's called slicing.
You can slice a sequence in python like this:
That returns all elements from index 1 to index 4. The index 4 is not included.
If you want all elements from index 1 to the end you are doing it like this:
Respectively, from the beginning to some index:
As you already have guessed the [:] notation is representing the whole sequence. From the beginning to the end. In fact a copy of ( in this case ) the list.
It's called slicing.
You can slice a sequence in python like this:
words[1:4]
.That returns all elements from index 1 to index 4. The index 4 is not included.
If you want all elements from index 1 to the end you are doing it like this:
words[1:]
.Respectively, from the beginning to some index:
words[:4]
.As you already have guessed the [:] notation is representing the whole sequence. From the beginning to the end. In fact a copy of ( in this case ) the list.