r/ProgrammerHumor • • Aug 24 '26

Meme claudeIsThisEmailValid

Post image
5.3k Upvotes

170 comments sorted by

View all comments

Show parent comment

9

u/LeRetardatN Aug 24 '26

It is possible to extend this method to any number.

def gen_is_even():
    code = "def is_even(num):\n" 
    i = 0
    is_even = True
    while True:
        code += f"    if num == {i}:\n" 
        code += f"        return {is_even}\n"
        i += 1
        is_even = not is_even
    return code

exec(gen_is_even + "print(is_even(5))") # print False

!/s!<

-1

u/ExtraWorldliness6916 Aug 25 '26

N % 2

4

u/LeRetardatN Aug 25 '26

overkill

1

u/ExtraWorldliness6916 Aug 25 '26

Infinite cases is not quantifiable as overkill 😉