In two lines of input, you have a collection with a few elements and one word, respectively. Write a function dropElements(), which drops all the occurrences of that word from the collection and returns a new list.
Collections as interface
Cut the collection
Report a typo
Sample Input 1:
pancakes eggs waffles sausages eggs bacon vegetables eggs muffins crumpets toast eggs
eggsSample Output 1:
[pancakes, waffles, sausages, bacon, vegetables, muffins, crumpets, toast]
[pancakes, waffles, sausages, bacon, vegetables, muffins, crumpets, toast]Write a program in Kotlin
fun main() {
val originalList = readln().split(" ")
val originalSet = originalList.toSet()
val word = readln()
println(dropElements(originalList, word))
println(dropElements(originalSet, word))
}
// Write function dropElements() here
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.