3 ms·
The analogous for loop would have you compute n from the size of y. You still don’t know, statically, the length of the loop in that case unless you statically
by Jtsummers 5y ago
The analogous for loop would have you compute n from the size of y. You still don’t know, statically, the length of the loop in that case unless you statically know the size or length of y.
It has the same problem either way. Similarly, if you always know the size of n in the C style loop, then you would always know the size of y in the Python style loop.
The Python loop just has the benefit of being shorter (by a line and a few tokens).