try Statement with Multiple excepts : Error Exception : Statement PYTHON TUTORIALS


PYTHON TUTORIALS » Statement » Error Exception »

 

try Statement with Multiple excepts


def safe_float(obj):
    try:
         retval = float(obj)
    except ValueError:
        retval = 'could not convert non-number to float'
    except TypeError:
        retval = 'object type cannot be converted to float'
    return retval



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Statement
» Error Exception