Kotlin lists

Report a typo

Write code that prints the third row of inputList in one string. The elements should be separated by a comma and space.

It is guaranteed that inputList is already initialized and contains at least 3 nested lists.

Tip: Use the joinToString() function.

Sample Input 1:

val inputList = mutableListOf(
    mutableListOf("one", "two", "three"),
    mutableListOf("four", "five", "six"),
    mutableListOf("seven", "eight", "nine"),
    mutableListOf("ten", "eleven", "twelve")
)

Sample Output 1:

seven, eight, nine

Sample Input 2:

val inputList = mutableListOf(
    mutableListOf("(¬‿¬)_", "Program"),
    mutableListOf("_(^.^)/", "with"),
    mutableListOf("(>^_^)>", "Kotlin!")
)

Sample Output 2:

(>^_^)>, Kotlin!

Sample Input 1:

4
(¬‿¬)_ Program
_(^.^)/ with
(>^_^)> Kotlin!
wrong row

Sample Output 1:

(>^_^)>, Kotlin!
Write a program in Kotlin
fun main() {
val inputList: MutableList<MutableList<String>> = mutableListOf()
val n = readLine()!!.toInt()
for (i in 0 until n) {
val stringsList = readLine()!!.split(' ').toMutableList()
inputList.add(stringsList)
}
// Do not change lines above
// Write your code here

}
___

Create a free account to access the full topic