Re:Neon Programming Language
by setpatchaddress on Thursday October 15, 2020 @06:34PM
(#24795023)
(1..100).each do |i|
puts case
when i % 15 == 0
'FizzBuzz'
when i % 3 == 0
'Fizz'
when i % 5 == 0
'Buzz'
else
i
end
end
Re:Neon Programming Language
by braindongle on Thursday October 15, 2020 @07:42PM
(#24795709)
Yes, cleaner, and no switch in Python.
(offtopic) You might be missing an '== 0' in the second line there? I've never done fizzbuzz so I honestly don't know, but the ruby version has it.
If I'm teaching an intro class using a general purpose language, it's Ruby or Python. My heart lies with Ruby, but having basic Python chops is such a bigger win downstream.