defisNumeric(s): # write code here iflen(s) == 0or s == '+'or s == '-'or s == 'e'or s == 'E'or s == '.': returnFalse numbers = ['0','1','2','3','4','5','6','7','8','9'] signs = ['+', '-'] e = ['e', 'E'] if s[0] notin numbers + signs: returnFalse if s[0] in signs: state = 0 else: state = 1 for i inrange(1, len(s)): if state == 0: if s[i] in numbers + ['.']: if s[i] in numbers: state = 1 else: state = 2 else: returnFalse elif state == 1: if s[i] in numbers + e + ['.']: if s[i] == '.': state = 2 elif s[i] in e: if i == len(s) - 1: returnFalse state = 3 else: returnFalse elif state == 2: if s[i] in numbers: state = 5 else: returnFalse elif state == 3: if s[i] in signs + numbers: state = 4 else: returnFalse elif state == 4: if s[i] notin numbers: returnFalse
elif state == 5: if s[i] in numbers + e: if s[i] in e: state = 3 else: returnFalse