3 ms·
Technically, we probably could, but would often need workarounds for code which changes the initial condition such as, i = 0 if i <= 0: i += 1 else
by hgsv 6y ago
Technically, we probably could, but would often need workarounds for code which changes the initial condition such as,
i = 0
if i <= 0:
i += 1
else:
i -= 1
You could of course solve this in various ways, for example something like:
condition = i <= 0
if condition:
i += 1
if not condition:
i -= 1
But i don't find that to read as well as an else block. Also restating longer conditions which we don't change in the then-block to mimic an else with an if seems like a waste of spacetime.