Python Check If Substring Exists Cast