Creating exclusive ranges in Kotlin May 5, 2023 by Tarik You can use the until function in the Kotlin stdlib: for (i in 1 until 5) { println(i) } Which will print: 1 2 3 4