So I have a function which reduces some dataset, and returns the number of elements removed. I have to stop applying it once the number of items reduced during the function’s operation is zero. Currently I’ve got this:
num_removed = reduction_pass(dataset)
while num_removed > 0:
num_removed = reduction_pass(dataset)
but these two variable assignments kind of get to me. Is there a more elegant way to write this?
I assume you don’t actually need the final return value, as I assume it indicates the number of removed elements, which will obviously always be 0 on the last pass.
The simple-is-better-than-complex way:
The showing-off, obviously-not-serious way: