#input
my_string = \'abcdefgABCDEFGHIJKLMNOP\'
how would one extract all the UPPER from a string?
#output
my_upper = \'ABCDEFGHIJKL
import string
s = 'abcdefgABCDEFGHIJKLMNOP'
s.translate(None,string.ascii_lowercase)
string.translate(s, table[, deletechars]) function will delete all characters from the string that are in deletechars, a list of characters. Then, the string will be translated using table (we are not using it in this case).
To remove only the lower case letters, you need to pass string.ascii_lowercase as the list of letters to be deleted.
The table
is None because when the table is None
, only the character deletion step will be performed.