4 ms·
He forgot one on the "i += 1" (which would be i++ in a for loop but Python doesn't have that operator). But that whole line is weird, because I think the C exa
by drivers99 13y ago
He forgot one on the "i += 1" (which would be i++ in a for loop but Python doesn't have that operator).
But that whole line is weird, because I think the C example should use a "for" loop, not increment the main counter at the top of a while loop, even if it has to use "for i in range(1, 101)" like in pythonic python. A C programmer like me (who loves python too) would immediately think "for (i = 1; i <= 100; i++)" for that (although counting from 1 is strange, it's what the problem asks for).
- eriktaubeneck 13y agoThis is what I originally had but I felt that the Python `while` was actually a bit more true to the way a C for loop is constructed (and `range` seems a very not C thing to do.) It's not perfect!