Skip to content

Add IndexError to tutorial datastructures list.pop doc #114648

@ShivnarenSrinivasan

Description

@ShivnarenSrinivasan

Documentation

In the Datastructures tutorial, the remove and index methods mention that an IndexError may be raised.
The tutorial is not intended to be an extensive reference, but I feel it is better to state the potential exception.

We could add the boldfaced text to the paragraph:

list.pop([i])
Remove the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list. It raises an IndexError if the list if the list is empty or the index is outside the list range. (The square brackets around the i in the method signature denote that the parameter is optional, not that you should type square brackets at that position. You will see this notation frequently in the Python Library Reference.)

Thoughts?

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc direasy

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions