Files
42_EXT_04_piscine_python/d00/ex03/NULL_not_found.py
2025-10-28 21:33:13 +01:00

29 lines
939 B
Python

def NULL_not_found(object: any) -> int:
nullType = type(object)
match object:
case None:
print("Nothing:", object, nullType)
# using a guard :
# https://docs.python.org/3/reference/compound_stmts.html#guards
# (NaN == NaN) = false :
# https://docs.python.org/3.10/reference/expressions.html#value-comparisons
# "A counter-intuitive implication is that not-a-number values are not
# equal to themselves"
case float() if object != object:
print("Cheese:", object, nullType)
# need check before int(), why ?
case bool() if object is False:
print("Fake:", object, nullType)
case int() if object == 0:
print("Zero:", object, nullType)
case str() if object == '':
print("Empty:", nullType)
case _:
print("Type not Found")
return 1
return 0