Check out example codes for "kotlin iterate list exclude last one". It will help you in understanding the concepts better.

Code Example 1

package com.zetcode

fun main() {

    val words = listOf("pen", "cup", "dog", "person",
            "cement", "coal", "spectacles")

    println()

    for (i in 0 until words.size - 1) {

        print("${words[i]} ")
    }
}

Learn ReactJs, React Native from akashmittal.com