/**
 * In this exercise, you are given a list of names and your task is to modify the list by replacing 
 * all occurrences of a specific old name with a new name. You need to perform this operation without 
 * using the ternary operator. The function takes three arguments: 'names' represents the list of names,
 * 'oldName' represents the name to be replaced, and 'newName' represents the name that replaces the oldName.
 * 
 * Your task is to write Kotlin code to solve the exercise by modifying the 'names' list.
 * 
 * Example:
 * // Input
 * val names = mutableListOf("Tom", "Jerry", "Tom", "Sylvester", "Jerry")
 * val oldName = "Tom"
 * val newName = "Bob"
 * 
 * // Output
 * println(names)
 * // Output: ["Bob", "Jerry", "Bob", "Sylvester", "Jerry"]
 */
fun replaceName(names: MutableList<String>, oldName: String, newName: String): MutableList<String> {

    for (i in names.indices) {
        if (names[i] == oldName) {
            names[i] = newName
        }
    }
    return names
}
/**
 * In this exercise, you are given a list of names and your task is to modify the list by replacing 
 * all occurrences of a specific old name with a new name. You need to perform this operation without 
 * using the ternary operator. The function takes three arguments: 'names' represents the list of names,
 * 'oldName' represents the name to be replaced, and 'newName' represents the name that replaces the oldName.
 * 
 * Your task is to write Kotlin code to solve the exercise by modifying the 'names' list.
 * 
 * Example:
 * // Input
 * val names = mutableListOf("Tom", "Jerry", "Tom", "Sylvester", "Jerry")
 * val oldName = "Tom"
 * val newName = "Bob"
 * 
 * // Output
 * println(names)
 * // Output: ["Bob", "Jerry", "Bob", "Sylvester", "Jerry"]
 */
fun replaceName(names: MutableList<String>, oldName: String, newName: String): MutableList<String> {
/**
 * In this exercise, you are given a list of names and your task is to modify the list by replacing 
 * all occurrences of a specific old name with a new name. You need to perform this operation without 
 * using the ternary operator. The function takes three arguments: 'names' represents the list of names,
 * 'oldName' represents the name to be replaced, and 'newName' represents the name that replaces the oldName.
 * 
 * Your task is to write Kotlin code to solve the exercise by modifying the 'names' list.
 * 
 * Example:
 * // Input
 * val names = mutableListOf("Tom", "Jerry", "Tom", "Sylvester", "Jerry")
 * val oldName = "Tom"
 * val newName = "Bob"
 * 
 * // Output
 * println(names)
 * // Output: ["Bob", "Jerry", "Bob", "Sylvester", "Jerry"]
 */
fun replaceName(names: MutableList<String>, oldName: String, newName: String): MutableList<String> {

    for (i in names.indices) {
        if (names[i] == oldName) {
            names[i] = newName
        }
    }
    return names
}