I have the following string foo
:
foo = 'F9B2Z1F8B30Z4'
Without using re
, I'd like to split on 'F' and then add 'F' back to the resulting list.
My attempt is:
['F'+elem for elem in foo.split('F')]
This gives us:
['F', 'F9B2Z1', 'F8B30Z4']
But, I was expecting:
['F9B2Z1', 'F8B30Z4']
Is it possible to modify the list comprehension to catch this case? If not, is there another approach that I can use?
Thanks!