Answer the question
In order to leave comments, you need to log in
How to not display strings in a list?
Wrote a function:
def diw(lust):
print([int(i) for i in lust])
diw([1, 2, 3, 23.9, 'sad'])
def diw(lust):
print([int(i) for i in lust])
diw([1, 2, 3, 23.9, 'sad'])
>>>> [1, 2, 3, 23]
Answer the question
In order to leave comments, you need to log in
def filter(array, typed):
return [el for el in array if type(el) is not typed]
def diw(lust):
return list(map(int, filter(lust, str)))
print(diw([1,2,3,23.9, 'sad'])) # [1,2,3,23]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question