Re: do something every 1000 records or so



Jo wrote:
Ok, this could be a perfect exam question, but it isn't and i need a
good solution

I'll believe you.

if beginRange == 0 || "some condition so it prints every 1000 records" {

I think you need the modulo (%) operator. This gives the remainder of an integer division, which will, of course be zero every n records when you modulo by n. For example 25 % 25 == 0, 50 % 25 == 0, 51 % 25 == 1 and so on.

--
Regards,

Richard
.



Relevant Pages

  • Re: overload builtin operator
    ... ZeroDivisionError: integer division or modulo by zero ...
    (comp.lang.python)
  • Re: Conditional iteration
    ... ZeroDivisionError: integer division or modulo by zero ...
    (comp.lang.python)
  • Re: Conditional iteration
    ... ZeroDivisionError: integer division or modulo by zero ...
    (comp.lang.python)
  • Re: overload builtin operator
    ... to his safediv function ...] ... ZeroDivisionError: integer division or modulo by zero ...
    (comp.lang.python)
  • Re: the dreaded %
    ... KyoGaSuki wrote: ... Even earlier in school, when we were 6 years old, we learned the integer division with remainder: ... The remainder 2 here is the modulo result. ...
    (comp.lang.java.programmer)