Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gettingwings opened this issue Sep 8, 2023 · 0 comments
Open

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

gettingwings opened this issue Sep 8, 2023 · 0 comments

Comments

@gettingwings
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant