Remove all the digits(0-9) from a string in Python

Python code to remove all digits from 0-9 in a string is :-

 

def remove_digits(input_string):
# Remove digits by iterating through characters
result = ”
for char in input_string:
if not char.isdigit():
result += char
return result

# Example usage
input_string = input(“Enter a string: “)
cleaned_string = remove_digits(input_string)
print(“String after removing digits:”, cleaned_string)

 

Sample output:-

Enter a string: anuja1211patil
String after removing digits: anujapatil

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top