I want to split data in a python list and take the index number 1, but the format in the list is not the same, some of the element does not need to be split because it has only one element.
a = ['a,b','b,c','d,e','e']
I apply the code:
a.apply(lambda x: x.split(',')[1])
When I run it, a[3] result in out of range error because it has no index 1. (Error message: IndexError: list index out of range)
How do I deal with this? I still want to split the remaining elements, but for the element that can't be split should remain as it is.