this post was submitted on 15 Jul 2025
459 points (94.9% liked)

Programmer Humor

37249 readers
46 users here now

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

Rules:

founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] kryptonianCodeMonkey@lemmy.world 21 points 3 days ago* (last edited 3 days ago) (1 children)
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 6 points 3 days ago* (last edited 3 days ago) (1 children)
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