Skip to content
Advertisement

How do I find the index of an unknown value in python?

So basically I have a list like this –

JavaScript

and I don’t know what val is. So how do I get the index of val (3) only knowing that it is not None

Advertisement

Answer

This one line solution gives you the first value that is not None.

JavaScript

This returns the actual value, to get the index, look into this answer first comment which is:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement