How to create a function that takes a list of non-negative integers and strings and return a new list without the strings?
Eg. filter_list([1, 2, "a", "b"])
? [1, 2]
Issue: Not able to convert output to list
def filter_list(a):
mylist=[]
if type(a)==list:
for i in a:
if type(i)==int:
output=print(i)
mylist+=output
return mylist
What am I doing wrong?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…