Substring Match In Python Syntax Error