Values & References14 / 18
Up next

Augmented assignment differs by type

a = [1, 2]
b = a
# += on a list mutates in place, so b sees it too
a += [3]
print(b)
x = 1
y = x
# += on an int rebinds a only
x += 1
print(y)
What you're solving

+= mutates a list but rebinds an int