How to extract only uppercase characters from a string in Python

1 Answer

0 votes
import re 

s = '#PY23thon#$% Prog(_)*&raMMing 123LAngu9837age'
  
result = [ch for ch in s if ch.isupper()] 

print(result)  

         
      
'''
run:
 
'P', 'Y', 'P', 'M', 'M', 'L', 'A'
      
'''

 



answered Apr 24, 2020 by avibootz

Related questions

...