<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_slice_location(dcmdata, teil=None):
 """ get location of the slice :param dcmdata: dicom data structure :param teil: filename. Used when slice location doesnt exist :return: """

    slice_location = None
    if hasattr(dcmdata, 'SliceLocation'):
        # print(dcmdata.SliceLocation)
        # print(type(dcmdata.SliceLocation))
        try:
            slice_location = float(dcmdata.SliceLocation)
        except Exception as exc:
            logger.info("It is not possible to use SliceLocation")
            logger.debug(traceback.format_exc())
    if slice_location is None and hasattr(dcmdata, "SliceThickness") and teil is not None:
        logger.debug(
            "Estimating SliceLocation wiht image number and SliceThickness"
        )

        # from builtins import map
        i = list(map(int, re.findall('\d+', teil)))
        i = i[-1]
        try:
            slice_location = float(i * float(dcmdata.SliceThickness))
        except ValueError as e:
            print(type(dcmdata.SliceThickness))
            print(dcmdata.SliceThickness)
            logger.debug(traceback.format_exc())
            logger.debug("SliceThickness problem")

    if slice_location is None and hasattr(dcmdata, "ImagePositionPatient") and hasattr(dcmdata,
                                                                                       "ImageOrientationPatient"):
        if dcmdata.ImageOrientationPatient == [1, 0, 0, 0, 1, 0]:
            slice_location = dcmdata.ImagePositionPatient[2]
        else:
            logger.warning("Unknown ImageOrientationPatient")
    if slice_location is None:
        logger.warning("Problem with slice location")

    return slice_location