To create a range which does not include its end element, you can use the until function:
for (i in 1 until 10) { // i in [1, 10), 10 is excluded println(i) }