indices

Returns the range of valid character indices for this char sequence.

val CharSequence.indices: IntRange(source)
fun main() {
    val word = "Kotlin"
    for (index in word.indices) {
        println("Character at index $index: ${word[index]}")
    }
}

Source