Loading Teachly…
An AI assistant wrote can_checkout(cart, has_payment_method) to return True only when the cart has items AND a payment method is on file. It nested the checks instead of handling each invalid case up front — and one case slipped through.
can_checkout(["item"], True) is True. can_checkout(["item"], False) is False. can_checkout([], True) is False (an empty cart is never ready). can_checkout([], False) is False.