Code - problem in last functions (Its Done)

Write a code to generate the first input multiples of 5 integers from 5 . If 3 is the input, the list must be List(5, 10, 15). Using the for loop, create an yieldedList with yield which contains elements smaller than 50 and are odd integers. Using another for loop, print all the multiples of 3 in the yieldedList .

I have done the folllowing code , please tell
code

You should just store the result of the for expression into a value:

val yieldedList = for (...) yield j

And please, use the triple backticks to paste code or indent them 4 spaces on each line (instead of pasting a picture – that is bad because nobody can copy the program text from your picture).

Also, include any compiler errors in triple backticks, and at least say where the problem is…

Thank you cbley.Sure, next time I am take care of it.

Thank you all. Its done :smiley:

1 Like

Is this the final code ?

object ForComprehensions2 extends App {
val input : Int = args(0).toInt
val list = List.tabulate(input)(n=>(n+1)*5)
val yieldedList = for(i <- list if i%2!=0 && i<50) yield j <-yieldedList
println(j)
}

still throws error. it is not working
Below is the error we got.
scalac ForComprehensions2.scala
ForComprehensions2.scala:5: error: β€˜;’ expected but β€˜<-’ found.
yield j <-yieldedList
^

Can you please help us what code worked for you ?

Thanks.