Skip to content

#26 Python del() and pop() #10

@LiuL0703

Description

@LiuL0703

Use del and specify the element you want to delete with the index:

 a = range(10)
 a      # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
 del a[-1]
 a      # [0, 1, 2, 3, 4, 5, 6, 7, 8]
a = ['a', 'b', 'c', 'd']
a.pop(1)
# now a is ['a', 'c', 'd']

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