DEV Community

Cover image for [Python] del statement
rorean
rorean

Posted on

[Python] del statement

What is it?

statement to delete

  • item in an object
del target["go"]
del target[0] # better to use pop() in the case of needing return value
del target[:] # better to use target.clear() explicitly
Enter fullscreen mode Exit fullscreen mode
  • binding of a name from the local or global namespace
del target
Enter fullscreen mode Exit fullscreen mode
  • attribute
del target.go
Enter fullscreen mode Exit fullscreen mode

Challenge

LeetCode 27. Remove Element

Reference

python documentation

Top comments (0)