I want to break a Python string into its characters.
sequenceOfAlphabets = list( string.uppercase )
works.
However, why does not
sequenceOfAlphabets = re.split( '.', string.uppercase )
work?
All I get are empty, albeit expected count of elements
The
'.'matches every character andre.splitreturns everything that wasn’t matched, that’s why you’re getting the empty list.Using
listis usually the way to handle something like this but if you want to use regular expressions just usere.findallThat should give you
['A', 'B', 'C', .... ,'Z']