Here is my solution:
def isNumber(s): try: int(s) return True except: pass try: float(s) return True except: pass if not any([x.isnumeric() for x in s]): return False if not s.isnumeric() or not s[-1].isnumeric(): return False pre_e = True pre_e_dot = False post_e_dot = False for char in s: if not char.isnumeric(): if char == "e": if not pre_e: pre_e = False continue else: return False if pre_e and char == ".": if not pre_e_dot: pre_e_dot = True continue else: return False if not pre_e and char == ".": if not post_e_dot: post_e_dot = True continue else: return False return False return True
But for some reason when I run my code I fail on only "+ 1". However, I just tried my solution offline and it handles that case fine. I'm wondering if anyone else has ever experienced one of these kinds of issues. To get my final submission to be accepted I had to specifically check if it was that one test case.