Say we have an array like a = [['a','b','c'], ['aber', 'jsfn', 'ff', 'fsf', '003'], [...] ...]
where each element can be of different size. What I want to do is to delete the last item of each sub-array if it matches the condition I set. So I have:
for x in range(len(a)):
if the last item in x matches some condition that is set:
then remove the last item from x
Since I am dealing with an array, I tried a.remove(-1)
but this is wrong. So, is there any simple way of doing this?
Just as an example, if I had:
for x in range(len(a)):
if the last element of each sub-array starts with an "S":
then remove the last item from that sub-array
How can I approach this? Any example or a link to some tutorial is much appreciated.