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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay