I've got a list with strings and integers and want to find the minimum value of the integers, without list-slicing. Is there a work-around?
arr = [5,3,6,"-",3,"-",4,"-"]
for i in range(len(set(arr))):
cut = min(arr)
Many Thanks!
You could filter the non numeric using a generator expression:
arr = [5,3,6,"-",3,"-",4,"-"]
result = min(e for e in arr if isinstance(e, int))
print(result)
Output
3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With