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)
SpeakinTelnet
joined 11 months ago
I don't care how much you think your code is readable, plain text comments are readable by everyone no matter the proficiency in the programming language used. That alone can make a huge difference when you're just trying to understand how someone handled a situation.
It was added in 3.10 and is surprisingly complete. The tutorial pep is a good starting point to see what it can accomplish