For Loop in Kotlin

Level 240 keystrokes

Iterates over the range 1 to 5 (both ends included) and prints each number.

Kotlin code

// 1..5 is a range from 1 to 5, including both ends
// i takes the values 1, 2, 3, 4, 5 in turn
1for (i in 1..5) {
// Prints "Count: " followed by the current value
2 println("Count: $i")
3}

Output

Count: 1
Count: 2
Count: 3
Count: 4
Count: 5
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Kotlin code and how often they appear.

  • .× 2
  • "× 2
  • (× 2
  • )× 2
  • :× 1
  • {× 1
  • }× 1
  • $× 1

More Kotlin examples at level 2

← Kotlin typing practice