Filter and Map in Scala usecase

I am stuck in below code :
Description:
ListFilter takes integer input from command line. A list must be generated with the input number of elements in the list starting from zero. Print the even numbers from the list using the filter function.

Code
object ListFilter{
def main(args :Array[String]) {
val input = args(0).toInt
val numberList =List(0,1,2)
val evenList = numberList.filter(_%2 ==0)
println(evenList)

I am getting correct output as List(0,2) but it is not marked as completed.

Please advise

You are missing the part of using input to generate a List from zero to it.
I am pretty sure that if you give a look to the documentation you can solve this pretty easily.

Thanks. Let me try

Thanks. It worked

1 Like