Why is this solution wrong even though it's giving what is asked?

z = 0
h = ""
n = ""
for i in range(len(x)):

    if x[i] == " ":
        z = 0 + 1
    elif z == 0:
        h = h + x[i]
    elif z != 0:
        n = n + x[i]

a = int(h)
b = float(n)

if a%5 == 0:
    if b>a:
        om = b-a
        ok = om-0.5
        float = "{:.2f}".format(ok)
        print(float)
    else:
        f = "{:.2f}".format(b)
        print(f)
else:
    f = "{:.2f}".format(b)
    print(f)

problem: Contest Page | CodeChef

Please post all of your code - this won’t run, as x is not defined before it is used!