How to extract all UPPER from a string? Python
extract, lowercase, python, string, uppercase
Solution
Using list comprehension:
>>> s = 'abcdefgABCDEFGHIJKLMNOP'
>>> ''.join([c for c in s if c.isupper()])
'ABCDEFGHIJKLMNOP'
Using generator expression:
>>> ''.join(c for c in s if c.isupper())
'ABCDEFGHIJKLMNOP
You can also do it using regular expressions:
>>> re.sub('[^A-Z]', '', s)
'ABCDEFGHIJKLMNOP'
Problem
``` #input my_string = 'abcdefgABCDEFGHIJKLMNOP' ``` how would one extract all the UPPER from a string? ``` #output my_upper = 'ABCDEFGHIJKLMNOP' ```