Java Function To Check Substring In String In Python