3 ms·
I have to work with stacks a lot and doing while (item := stack.pop()) is not None: # ... is a lot harder to get wrong than item = stack.pop() whil
by Sean1708 7y ago
I have to work with stacks a lot and doing
while (item := stack.pop()) is not None:
# ...
is a lot harder to get wrong than
item = stack.pop()
while item is not None:
# ...
item = stack.pop()
Really wish it was scoped though...
Edit: Just realised you were asking for an if-statement... but I think this is still a valid point.