use a regular expression. Also, this is an inappropriate use of a try/except as the ValueError is likely and not an exceptional case