-->
A pretty (common) use case is to have a variable update only upon a condition. For example updating a minLength value:
if minLength > len(cat)- len(dog):
minLength = len(cat) - len(cat)
Which is inefficient because it has to do the calculation twice, plus you have to type it out. Typically the optimization would be
lenDiff = len(cat) - len(dog):
if minLength > lenDiff:
minLength = lenDiff
With python’s walrus operator, you can do an assign statement inside an if statement
if minLength > lenDiff:= len(cat) - len(dog):
minLength = lenDiff