Counters show 0 after the loop

HenryWritesOP

I increment warn_count but it stays 0.

2

Comments 5

Log in to join the discussion.

Log in Create account
  1. EmmaCodesreplies: 3

    Where do you set it to 0?

    0
    1. HenryWritesOPreplies: 2

      Inside the for loop, at the top.

      2
      1. EmmaCodesreplies: 1

        That resets it on every iteration. Initialise the counters before the loop, increment inside it, print after it.

        4
        1. HenryWritesOP

          Moved it up, now WARN: 2, CRITICAL: 2.

          2
    2. CharlieH

      Before / inside / after the loop — the classic accumulator pattern.

      1