[Solved] Why did my regex not work for "-" in the earlier version of this Python code ?
Hi. I just realized one of my bits failed to throw an exception in accordance with my regex. I later changed the concerning part of the if statement to have the first predicate, an inequality, deal with it. Initially it was "if n >= 256 or r".*?\D" in str(n):" With this one negative inputs with the minus sign weren't dealt with by the regex but at the end due to the print statement conditional. So what's wrong with the regular expression, why does it work when other symbols are used but not with the minus sign? Edit: I gave it one last try, and wrote or re.match(r"^.*?\D?", str(n)) == True (also tried without the boolean assignment) didn't work. Started mixing things up :(. Going to bed now, I will be checking the replies later. Thanks in advance. https://code.sololearn.com/c6Jo1WdlWjkV/?ref=app