Jul-02-2018, 09:36 AM
(Jul-02-2018, 07:31 AM)wavic Wrote: Hello and welcome!
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.
Does that mean there are two lists with same name words?