andioop@programming.dev to Programming Horror@programming.dev • edit-21 year agoGod I wish there was an easier way to do thisimagemessage-square23 fedilinkarrow-up194
arrow-up194imageGod I wish there was an easier way to do thisandioop@programming.dev to Programming Horror@programming.dev • edit-21 year agomessage-square23 Commentsfedilink
minus-squareSpeakinTelnet@programming.devhexbear7·edit-21 year agodef is_even(n): match n: case 1: return False case 0: return True # fix No1 case n < 0: return is_even(-1*n) case _: return is_even(n-2) linkfedilink
def is_even(n): match n: case 1: return False case 0: return True # fix No1 case n < 0: return is_even(-1*n) case _: return is_even(n-2)
What if the input is negative
Fixed!