lst = ['a1', '', 'c1', '', '']

def remove_while(lst):
    return ','.join(lst).rstrip(', ').split(',')
remove_while(['a1', '', 'c1', '', ''])
How to remove leftmost/rightmost elements in list that satisfy a certain criterion in python?