/**
 * This exercise requires you to write a function that finds the positions of a specific character within a given string.
 * You need to use a loop to iterate through each character in the string and a ternary operator to check if the current character matches the target character.
 *
 * @param string The input string in which to find the character.
 * @param char The target character to find.
 * @return A list containing the positions (indices) at which the target character is found.
 *
 * Example:
 * val string = "Hello, world!"
 * val targetChar = 'o'
 * findCharInString(string, targetChar)
 * Output: [4, 8]
 */
fun findCharInString(string: String, char: Char): List<Int> {

    val positions = mutableListOf<Int>() // Create an empty list to store the positions of the target character
    
    for (index in string.indices) { // Iterate through each character in the string
        if (string[index] == char) {
            positions.add(index) // Add index to the list if current character matches target character
        }
    }
    
    return positions
}
/**
 * This exercise requires you to write a function that finds the positions of a specific character within a given string.
 * You need to use a loop to iterate through each character in the string and a ternary operator to check if the current character matches the target character.
 *
 * @param string The input string in which to find the character.
 * @param char The target character to find.
 * @return A list containing the positions (indices) at which the target character is found.
 *
 * Example:
 * val string = "Hello, world!"
 * val targetChar = 'o'
 * findCharInString(string, targetChar)
 * Output: [4, 8]
 */
fun findCharInString(string: String, char: Char): List<Int> {
/**
 * This exercise requires you to write a function that finds the positions of a specific character within a given string.
 * You need to use a loop to iterate through each character in the string and a ternary operator to check if the current character matches the target character.
 *
 * @param string The input string in which to find the character.
 * @param char The target character to find.
 * @return A list containing the positions (indices) at which the target character is found.
 *
 * Example:
 * val string = "Hello, world!"
 * val targetChar = 'o'
 * findCharInString(string, targetChar)
 * Output: [4, 8]
 */
fun findCharInString(string: String, char: Char): List<Int> {

    val positions = mutableListOf<Int>() // Create an empty list to store the positions of the target character
    
    for (index in string.indices) { // Iterate through each character in the string
        if (string[index] == char) {
            positions.add(index) // Add index to the list if current character matches target character
        }
    }
    
    return positions
}