/**
 * This exercise requires creating a range with start and stop parameters. You need to implement a function
 * that iterates over the provided range. Within the iteration, you must implement nested try-except statements
 * to handle potential errors in the code block.
 *
 * @param start The starting value for the range.
 * @param stop The end value for the range.
 * @return A list containing all the values between start and stop (inclusive) that are divisible by 3.
 */
fun nestedTryExcept(start: Int, stop: Int): List<Int> {

    try {
        val result = mutableListOf<Int>()
        for (i in start..stop) {
            try {
                if (i % 3 == 0) {
                    result.add(i)
                }
            } catch (e: ArithmeticException) {
                // Handle specific exception if needed
            }
        }
        return result
    } catch (e: TypeCastException) {
        println("Invalid arguments: start and stop must be integers.")
        return emptyList()
    } catch (e: Exception) {
        println("Error occurred: $e")
        return emptyList()
    }
}
/**
 * This exercise requires creating a range with start and stop parameters. You need to implement a function
 * that iterates over the provided range. Within the iteration, you must implement nested try-except statements
 * to handle potential errors in the code block.
 *
 * @param start The starting value for the range.
 * @param stop The end value for the range.
 * @return A list containing all the values between start and stop (inclusive) that are divisible by 3.
 */
fun nestedTryExcept(start: Int, stop: Int): List<Int> {
/**
 * This exercise requires creating a range with start and stop parameters. You need to implement a function
 * that iterates over the provided range. Within the iteration, you must implement nested try-except statements
 * to handle potential errors in the code block.
 *
 * @param start The starting value for the range.
 * @param stop The end value for the range.
 * @return A list containing all the values between start and stop (inclusive) that are divisible by 3.
 */
fun nestedTryExcept(start: Int, stop: Int): List<Int> {

    try {
        val result = mutableListOf<Int>()
        for (i in start..stop) {
            try {
                if (i % 3 == 0) {
                    result.add(i)
                }
            } catch (e: ArithmeticException) {
                // Handle specific exception if needed
            }
        }
        return result
    } catch (e: TypeCastException) {
        println("Invalid arguments: start and stop must be integers.")
        return emptyList()
    } catch (e: Exception) {
        println("Error occurred: $e")
        return emptyList()
    }
}