if ip_str starts with ':, but it doesnt starts with '::', or if ip_str ends with ':, but it doesnt ends with '::',
if ( ( ip_str . startswith ( ':' ) and not ip_str . startswith ( '::' ) ) or ( ip_str . endswith ( ':' ) and not ip_str . endswith ( '::' ) ) ) :