/**
 * This exercise is designed to evaluate your understanding of exiting while loops
 * using string slicing. Your task is to complete the function to find the index of
 * the first occurrence of a specified word in a given string and return a new string
 * containing the characters before that word.
 *
 * @param string The input string to be analyzed.
 * @return The new string consisting of the characters before the specified word.
 *
 * Example:
 * exitWhileLoopAthlete("I am an athlete and I love sports.")
 * Output: "I am an athlete "
 */
fun exitWhileLoopAthlete(string: String): String {

    // Set the target word to search for
    val targetWord = "athlete"
    
    // Initialize the index counter
    var index = 0
    
    // Initialize the final string
    var finalString = ""
    
    while (index < string.length) {
        // Check if the target word is present at current index
        if (string.substring(index, index + targetWord.length) == targetWord) {
            break
        }
        
        // Append the current character to the final string
        finalString += string[index]
        
        // Increment the index
        index++
    }
    
    return finalString
}
/**
 * This exercise is designed to evaluate your understanding of exiting while loops
 * using string slicing. Your task is to complete the function to find the index of
 * the first occurrence of a specified word in a given string and return a new string
 * containing the characters before that word.
 *
 * @param string The input string to be analyzed.
 * @return The new string consisting of the characters before the specified word.
 *
 * Example:
 * exitWhileLoopAthlete("I am an athlete and I love sports.")
 * Output: "I am an athlete "
 */
fun exitWhileLoopAthlete(string: String): String {
/**
 * This exercise is designed to evaluate your understanding of exiting while loops
 * using string slicing. Your task is to complete the function to find the index of
 * the first occurrence of a specified word in a given string and return a new string
 * containing the characters before that word.
 *
 * @param string The input string to be analyzed.
 * @return The new string consisting of the characters before the specified word.
 *
 * Example:
 * exitWhileLoopAthlete("I am an athlete and I love sports.")
 * Output: "I am an athlete "
 */
fun exitWhileLoopAthlete(string: String): String {

    // Set the target word to search for
    val targetWord = "athlete"
    
    // Initialize the index counter
    var index = 0
    
    // Initialize the final string
    var finalString = ""
    
    while (index < string.length) {
        // Check if the target word is present at current index
        if (string.substring(index, index + targetWord.length) == targetWord) {
            break
        }
        
        // Append the current character to the final string
        finalString += string[index]
        
        // Increment the index
        index++
    }
    
    return finalString
}