• I don't understand why it doesn't work :(.

Question related to mission Reveal the Number

def reveal_num(line: str) -> int | float | None:

    result =""
    for char in line:
        if char.isdigit():
            result += char
        elif char == '-' or char == '.' and not result:
            result += char

    if len(result)==0:
        return None
    elif result[0]=='-' or result[1]=='+':
        return float(''.join(result[1::]))
        return float(''.join(result))