+ 1

Bug in a Kotlin Challenge

Something weird happening in a Kotlin Pro challenge. Chapter "Control Flow", section "For Loops" The challenge statement is in the following: ====================================================== Vertical Text You need to make a string as input and output it vertically, each letter on a new line. . Sample Input: hello . Sample Output: h e l l o Use a for loop to iterate over the letters of the string. ============================================================ If you just print the input horizontally, it already congratulates you as if you have solved the problem I think the supposed solution would be: ----------------------------------------------------------------------------------------- fun main(args: Array) { var a = readLine() for(i in a){ println(i) } } -------------------------------- But the code doesn't run!

3rd Apr 2021, 5:55 PM
Lucas Kliemczak
Lucas Kliemczak - avatar
5 Answers
+ 4
Lucas Kliemczak Yes I already reported this but didn't get any response. To complete this task just print input value println(a)
3rd Apr 2021, 6:44 PM
A͢J
A͢J - avatar
+ 1
Write code for this question is :- fun main(args:Array<String>) { val a = readLine() if (a != null) { for (x in a) { println(x) } } }
25th Aug 2021, 7:26 AM
Premjeet Singh
Premjeet Singh - avatar
0
Report to sololearn by info@sololearn.com or use the in-app bug report for suggestion.
3rd Apr 2021, 6:29 PM
Aditya
Aditya - avatar
0
You can add " !! " in readLine(), i think like... fun main(args: Array<String>) { val input = readLine()!! for(x in input){ println(x) } }
1st Jun 2022, 3:55 AM
Muhammad Feri Candra Wijaya
Muhammad Feri Candra Wijaya - avatar
0
There is no Bug ,I did this code and it worked.... Try it and let me know weather it is working or not. fun main() { //print("Enter a string: ") val inputString = readLine() if (inputString != null) { val charArray = inputString.toCharArray() for (char in charArray) { println(char) } } }
17th Aug 2023, 6:41 PM
Muhammad Munir
Muhammad Munir - avatar