cara menggunakan assert dalam python
assert type(num) is int,"num must be an integer"
Sore Seal
assert type(num) is int,"num must be an integer"
# AssertionError with error_message.
x = 1
y = 0
assert y != 0, "Invalid Operation" # denominator can't be 0
print(x / y)
x = "aaa"
#if condition returns False, AssertionError is raised:
assert x == "aaa", "x should be 'aaa'"