Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,924 questions

51,857 answers

573 users

How to remove all digits from a list of strings in Python

2 Answers

0 votes
import re 

def remove_digits(lst): 
    pattern = '[0-9]'
    lst = [re.sub(pattern, '', c) for c in lst] 
    return lst
  
lst = ['12python', 'java76script', 'node.js56', '2c++2'] 

lst = remove_digits(lst)
 
print(lst)
 
      
     
'''
run:

['python', 'javascript', 'node.js', 'c++']
     
'''

 



answered Mar 27, 2020 by avibootz
0 votes
def remove_digits(lst): 
    lst = [''.join(c for c in i if c.isalpha()) for i in lst] 
    return lst
  
lst = ['12python', 'java76script', 'node.js56', '2c++2'] 

lst = remove_digits(lst)
 
print(lst)
 
      
     
'''
run:

['python', 'javascript', 'nodejs', 'c']
     
'''

 



answered Mar 27, 2020 by avibootz
...