460
you are viewing a single comment's thread
view the rest of the comments
[-] kryptonianCodeMonkey@lemmy.world 21 points 1 week ago* (last edited 1 week ago)
def is_even(num):
    if num == 1:
        return False
    if num == 2:
        return True
    raise ValueError(f'Value of {num} out of range. Literally impossible to tell if it is even.')
[-] VitabytesDev@feddit.nl 6 points 1 week ago* (last edited 1 week ago)
def is_even(num):
    num = num & 1
    if num == 0:
        return False
    if num == 1:
        return True
    raise ValueError(f'what the fuck')

EDIT: forgor to edit the numbers

If you're waiting for "num & 1 == 2", you're going to be very disappointed

this post was submitted on 15 Jul 2025
460 points (94.7% liked)

Programmer Humor

37334 readers
430 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS