assert in its constructor.
class Box:
def __init__(self, size):
assert size > 0, "no size"
self.size = size
made = []
for s in (3, 0, 2):
try:
made.append(Box(s))
except AssertionError as e:
print(e, end=" ")
print(len(made), made[-1].size)
What does the program print?Log in to join the discussion.
Loading…