I'm inexperienced in Python and started with Python 3.4.
I read over the Python 3.x documentation on loop idioms, and haven't found a way of constructing a familiar C-family for-loop, i.e.
for (i = 0; i < n; i++) {
A[i] = value;
}
Writing a for-loop like this in Python seems all but impossible by design. Does anyone know the reason why Python iteration over a sequence follows a pattern like
for x in iterable: # e.g. range, itertools.count, generator functions
pass;
Is this more efficient, convenient, or reduces index-out-of-bounds exception?
for i in range(n):
is fine. See PEP284. – NightShadeQueen Jul 14 '15 at 0:25