Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8667209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:54:41+00:00 2026-06-12T17:54:41+00:00

How can I remove digits from a string?

  • 0

How can I remove digits from a string?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:54:42+00:00Added an answer on June 12, 2026 at 5:54 pm

    Would this work for your situation?

    >>> s = '12abcd405'
    >>> result = ''.join([i for i in s if not i.isdigit()])
    >>> result
    'abcd'
    

    This makes use of a list comprehension, and what is happening here is similar to this structure:

    no_digits = []
    # Iterate through the string, adding non-numbers to the no_digits list
    for i in s:
        if not i.isdigit():
            no_digits.append(i)
    
    # Now join all elements of the list with '', 
    # which puts all of the characters together.
    result = ''.join(no_digits)
    

    As @AshwiniChaudhary and @KirkStrauser point out, you actually do not need to use the brackets in the one-liner, making the piece inside the parentheses a generator expression (more efficient than a list comprehension). Even if this doesn’t fit the requirements for your assignment, it is something you should read about eventually 🙂 :

    >>> s = '12abcd405'
    >>> result = ''.join(i for i in s if not i.isdigit())
    >>> result
    'abcd'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I (fastest preferable) remove commas from a digit part of a string
we can remove formula from one cell by cell.setCellFormula(null) . but if i want
How we can remove an array entry from : var a = [],b =
How to I can remove posts from a specific category from homepages in wordpress?
I am wondering How i can remove a part if my string . For
If I want to remove all ones from a string using boost::erase_all , I
How can I replace following string in Java: Sports videos (From 2002 To 2003)
One can remove all calls to printf() using #define printf . What if I
Is there a way I can remove the background bar image in the SeekBar
I am looking for an API that can remove bundle items added in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.