def ensure_unquoted(cookie_str):
 for _ in range(3):
  new_str = unquote(cookie_str)
  if (new_str == cookie_str):
   return new_str
  cookie_str = new_str

def ensure_unquoted ( cookie_str ) : for _ in range ( 3 ) : new_str = unquote ( cookie_str ) if ( new_str == cookie_str ) : return new_str cookie_str = new_str
keep unquoting .