processing-py-site icon indicating copy to clipboard operation
processing-py-site copied to clipboard

Index starts from 1 not 0 for this example of slice

Open gettingwings opened this issue 2 years ago • 0 comments

Use a colon inside the index brackets to get a "slice" of the list, returned as a list. element_slice = elements[1:5] # from index 0 up to (not including) index 5 print(element_slice) # Prints ['He', 'Li', 'B', 'C']

-------------corrected below ----------------

from index 1 up to (not including) index 5

Index starts from 1 not 0 for this example of slice

gettingwings avatar Sep 08 '23 15:09 gettingwings