OneBug This week's bugs
Spot the bug Python
1
def apply_discounts(prices, applied=[]):
2
    total = 0
3
    for p in prices:
4
        discounted = round(p * 0.9, 2)
5
        applied.append(discounted)
6
        total += discounted
7
    print(f"Applied {len(applied)} discounts so far")
8
    return total
9
 
10
cart_a = apply_discounts([100.0, 50.0])
11
cart_b = apply_discounts([20.0])
12
print(cart_b, "->", len(apply_discounts.__defaults__[0]))

Read the full write-up for this bug (spoilers)