def fractionToFloat(fraction): a = fraction.split(" ") whole = a[0] num = float(whole) if len(a) > 1: frac = a[1].split("/") num += float(frac[0]) / float(frac[1]) return num print fractionToFloat('1/3')
Standard input is empty
Standard output is empty
Traceback (most recent call last): File "prog.py", line 15, in <module> File "prog.py", line 6, in fractionToFloat ValueError: invalid literal for float(): 1/3
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!