I have a string:
s = '1234 Q-24 2010-11-29 563 abc a6G47er15 '
and I want to convert it into an Array with spaces.
['1234', ' ', 'Q-24', '2010-11-29', ' ', ' ', '563', 'abc', 'a6G47er15', ' ', ' ']
Please help me I am new with python
This may be enough:
parts = re.split(r'( )', s)
The regex split() function returns an array made by breaking the second argument at each match to the first argument. Normally, the matches themselves (in this case, each space) are discarded. But with the parentheses (called a "capture" in regex-speak), they are kept as separate items in the array as well.
-s
' 'strings in the output determined? - Martijn Pietersspaces range is not defined: nobody can help you if you don't know exactly what you want... - stellasia