This is my code so far
def filter_list2(elements):
for a in elements:
if a == (int(a) or float(a)) and a >= 1 and a < 50:
elements.append(a)
else:
elements.pop(a)
return elements
I want to change the following list:
filter_list2([0,10,55])
Into this:
[10]
I know pop is out of range. Is there something im missing? How can I convert my list into my result. Is pop the wrong approach?
EDIT:
def filter_list2(elements):
for a in elements:
if a == (int(a) or float(a)) and a >= 1 and a < 50:
continue
else:
elements.remove(a)
return elements
Does not work for 'abc'. How can I fix it?