Value Error Handling

[Solved] Value Error Handling | Vb - Code Explorer | yomemimo.com
Question : Value Error handling

Answered by : defiant-dog-n3mmrasfopy6

def conv(s): try: s=float(s) except ValueError: pass return s
print [conv(s) for s in ['1.1','bls','1','nan', 'not a float']]
# [1.1, 'bls', 1.0, nan, 'not a float']

Source : https://stackoverflow.com/questions/18877484/changing-strings-to-floats-in-an-imported-csv | Last Update : Sat, 31 Jul 21

Answers related to value error handling

Code Explorer Popular Question For Vb