def compact_list(uncompacted_list, single_item_out=str):
    """
	This takes a list like [1, 2, 3, 5, 7] and turns it into ['1-3', 5, 7]
	:param uncompacted_list:
	:return:
	"""
    new_list = []
    startrange = None
    for i in range(0, uncompacted_list.__len__()):
        if i + 1 < uncompacted_list.__len__():
            if uncompacted_list[i] + 1 == uncompacted_list[i + 1]:
                if startrange == None:
                    startrange = uncompacted_list[i]
                else:
                    pass
            elif startrange:
                new_list.append('{}-{}'.format(str(startrange),
                    uncompacted_list[i]))
                startrange = None
            else:
                if single_item_out == str:
                    new_list.append(str(uncompacted_list[i]))
                if single_item_out == int:
                    new_list.append(uncompacted_list[i])
        elif startrange:
            new_list.append('{}-{}'.format(str(startrange),
                uncompacted_list[i]))
            startrange = None
        else:
            if single_item_out == str:
                new_list.append(str(uncompacted_list[i]))
            if single_item_out == int:
                new_list.append(uncompacted_list[i])
    return new_list
