Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
10th Mar 2021, 8:25 AM
Simba
Simba - avatar
+ 5
for this kind of task, the do ... while loop could be a good solution: fun main(args: Array<String>) { var count = 0 do{ var num = readLine()!!.toInt() count++ } while (num != 0) println(count - 1) }
20th Aug 2021, 10:41 AM
Lothar
Lothar - avatar
+ 1
fun main(args: Array<String>) { var i= 0 while(true) { var input = readLine()!!.toInt() i++ if(input==0) break } println(i-1) } -- I hope this code helped!
21st Apr 2021, 2:50 PM
Cece