['1', 'a', '2', 'b', '3'] >>> list(filter_map(lambda s: int(s) if s.isnumeric() else None, elems)) [1, 2, 3] Nrß