+ 1
max value problem
I know i am missing something as the test fail but I am stuck on what I am missing https://code.sololearn.com/cctTifoTM92U
4 Respuestas
+ 3
If input_list has no integers then [i for i in input_list if isinstance(i, int)] is an empty list.
max([]) throws an error. You can fix it by doing something like this:
a = max([i for i in input_list if isinstance(i, int)] or "_")
+ 3
Michael Harrall I'm pretty sure there are other ways to fix your problem (ibra Kht just gave another solution). Using "or" seems the most simple to me.
+ 1
@Diego thank you so much cant believe that was it just that dang or statement i had thought about that but was not sure what to go with.
+ 1
In python max() function doesn't like Empty list, so in your code if the input_list doesn't have an integer value then you will get an error, thus you should check that the list is empty or not, then if it is not empty get its max value.