how to handle syntax error in Python