Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I love code golf as much as anyone, not sure it's worth it on such small methods tho. Any of the propositions would be fine. Anyway:

    def oddness(n):
      return ["Even", "Odd"][n % 2]
BTW this trick with replacing if-then-else with a lookup is sometimes very useful. Especially if there's many ifs.


Or your write in APL




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: