In Kotlin, you're given a MutableList of integer numbers and your task is to double the value of each element in the list. To achieve this, you need to traverse the list using a 'for' loop and manipulate each element. Then print the altered list in a string format using the 'joinToString()' function. Can you fill in the blanks in the provided code to accomplish this task? Remember to make use of the Kotlin's 'for' loop and ranges.
For loop and lists
Doubling values in a list using a for loop
Report a typo
Fill in the gaps with the relevant elements
fun main() {
val myList: <Int> = mutableListOf(1, 2, 3, 4, 5)
(i in 0 myList.size) {
myList[i] = myList[i] * 2
}
print(myList.joinToString())
}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.