---
title: "Discussion on \"Clear Digits\" | Hashnode"
description: "Discussion on \"Clear Digits\". You are given a string s.\nYour task is to remove all digits by doing this operation repeatedly:\n\nDelete the first digit and the closest non-digit character to its left.\n\nReturn the resulting string after removing all digits.\ndef clearDigits(self, s: ..."
url: "https://hashnode.com/posts/clear-digits/67abdf167e6d754d8ca561fb"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Clear Digits](https://khushaalan.hashnode.dev/clear-digits?utm_source=hashnode&utm_medium=feed)

You are given a string s. Your task is to remove all digits by doing this operation repeatedly: Delete the first digit and the closest non-digit character to its left. Return the resulting string after removing all digits. def clearDigits(self, s: ...

Feb 11, 2025 · 1 min read · khushaalan.hashnode.dev  
Read the article

-   [#string](https://hashnode.com/tag/string)
-   [#stack](https://hashnode.com/tag/stack)
-   [#easy](https://hashnode.com/tag/easy)

## Written by

[khushaalan](https://hashnode.com/@khushaalan)

@khushaalan · San Francisco

  
[View profile](https://hashnode.com/@khushaalan)

Software Dev

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
