Suppose you are given a piece of partially finished Kotlin code. The purpose of this code is to create a string that logs each iteration of a loop over a certain range, and then print that string. Your task is to fill the blanks in the code to complete the Kotlin range-based 'for' loop and ensure it works as expected. Don't forget to handle the range of iterations in the proper way.
For loop and ranges
Completing a range-based loop in given code
Report a typo
Fill in the gaps with the relevant elements
fun main() {
var result = ""
(i ) {
result += "Loop iteration: $i\n"
}
(result)
}Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.