1
I have this code and I can’t get the number -1 to be shown. It gives an error:
not supported between instances of 'str' and 'int'.
From what I’ve seen on other forums it has to do with comparing strings with integers. How can I overcome this?
list1=[2,2, 'a', 31, int(-1), 'b']
list2=[1, 3, 40]
list1[len(list1):]=list2
list1.append(5)
print (len(list1))
print (sorted (list1[7:]))
print (min(list1))
print (list1)
An alternative is to do:
min([x for x in list1 if type(x) in (int, float)])
– Woss