Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Yes, the function even_or_odd returns the string "Even" if the input n is even and "Odd" if the input n is odd
what do yall think? :D
alright i'm sorry
Hi Sara,
I would suggest you to try to run the code. The module operator (%) return the reminder in the division between the first and the second number. 6 divided by 2 is 3 with 0 as remainder, so in this code would be select the first item in the tuple, "Even", that is correct. Your version is easier to understand and more suitable for python, but the code written by graf_da still works.
if i enter "6", your code will throw KeyError because 6 % 2 == 2. so i'd rather do
Wow! Very smart idea. :)
Just use %2 to condense this into one condition. It will save loads of run time.
I've been writing it like that for 2 years? While yes it is pretty obvious, there are other ways of solving it. Either way you write it, in the end if it works it works, no big deal.
Fair enough.
You're correct. I'm only trying to raise awareness of the fact, and hopfully spur creativity in other user's to develop something beyond the, "fairly obvious way of writing it."
Fairly obvious way of writing it though.
This is a carbon-copy of dancing.swords solution 12 day ago...
Oh boy, the makings of a FizzBuzz function. I love CW so much.
It's because the solution is technically a 'full / real' one-liner. The second best solution below technically speaking, is two lines since it is defining the function as well. This solution is only one line which is why it is above the one below. And if that isn't why then feel free to correct me.
This comment is hidden because it contains spoiler information about the solution
Loading more items...