Home > other >  How to extract all the text from a file using python
How to extract all the text from a file using python

Time:10-10

I have a string like :- 'hi125get9itwhat8989'

How could I extract only the that is 'higetitwhat'

In Python

CodePudding user response:

Check this out: https://www.w3schools.com/python/ref_string_isalpha.asp

Make a for loop for instance for x in word and than check every x if its a letter using x.isAlpha() and you can just add it to a new string

res = ""
for x in word:
    if x.isalpha():
        res  = ch
print(res)

CodePudding user response:

You can do this using .isdigit()

    text = "hi125get9itwhat8989"
    chars = [i for i in text if not i.isdigit()]
    clean_text = ''.join(chars)
  • Related