Search code examples
pythonnon-english

How to remove english alphabets from list in python


I have a list with some English text while other in Hindi. I want to remove all elements from list written in English. How to achieve that?

Example: How to remove hello from list L below?

L = ['मैसेज','खेलना','दारा','hello','मुद्रण']  

for i in range(len(L)):    
    print L[i]

Expected Output:

मैसेज    
खेलना    
दारा    
मुद्रण

Solution

  • You can use isalpha() function

    l = ['मैसेज', 'खेलना', 'दारा', 'hello', 'मुद्रण']
    for word in l:
        if not word.isalpha():
            print word
    

    will give you the result:

    मैसेज
    खेलना
    दारा
    मुद्रण