isinstance() can be used to check if a given value is numeric or not.
Here is an example to test the elements of a list:
aa = [3, 4, "6", "8", 9]for v in aa: if isinstance(v, (int, float)): print("Value {0} is numeric".format(v)) else: print("Value {0} is not numeric".format(v))
The above code will print the following:
Value 3 is numericValue 4 is numericValue 6 is not numericValue 8 is not numericValue 9 is numeric