I don't understand why it doesn't work :(.
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::])) else: return float(''.join(result))