def net_amount(amount, *, refund=0):
    if amount is None or refund is None or not 0 <= refund <= amount:
        raise ValueError("amount/refund violate contract")
    return amount-refund

def collect(value, items=None):
    result=[] if items is None else list(items)
    result.append(value)
    return result

def mean_or_none(values):
    return sum(values)/len(values) if values else None

assert net_amount(100,refund=20)==80
assert collect(1)==[1] and collect(2)==[2]
original=[9]; changed=collect(1,original)
assert original==[9] and changed==[9,1]
assert mean_or_none([]) is None
try:
    net_amount(10,refund=11)
except ValueError:
    print("invalid refund rejected")
else:
    raise AssertionError("invalid input accepted")
print("net",net_amount(100,refund=20),"mean",mean_or_none([10,20]))
