New course! Every coder should learn Generative AI!
Try a free lesson0
This wonāt work on SoloLearn š¢
Why does this not work on Sololearn but it works in Repl (and in irb)? def check(x) if x == "Grr" return "Lion " Ā Ā elsif x == "Rawr" Ā Ā Ā return "Tiger " Ā Ā elsif x == "Chirp" Ā Ā Ā return "Bird " Ā Ā else Ā Ā Ā return "Snake " Ā Ā end end animals = gets.chomp.split(" ") for i in 0..(animals.count)-1 Ā print check(animals[i]) end
2 Answers
+ 1
Sololearns codeplayground is not propperly devoleped yet
Or sl uses dif version of ruby
0
Iāve got it working now...I removed all the indents šš»
def check(x)
if x == "Grr"
return "Lion "
elsif x == "Rawr"
return "Tiger "
elsif x == "Chirp"
return "Bird "
else
return "Snake "
end
end
animals = gets.chomp.split(" ")
for i in 0..(animals.count)-1
print check(animals[i])
end