Skip to content

Index starts from 1 not 0 for this example of slice #218

@gettingwings

Description

@gettingwings

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions