• Moredekai@lemmy.world
    link
    fedilink
    arrow-up
    37
    ·
    8 hours ago

    It’s a standard formatted for-loop. It’s creating the integer variable i, and setting it to zero. The second part is saying “do this while i is less than 10”, and the last part is saying what to do after the loop runs once -‐ increment i by 1. Under this would be the actual stuff you want to be doing in that loop. Assuming nothing in the rest of the code is manipulating i, it’ll do this 10 times and then move on

    • Fermion@feddit.nl
      link
      fedilink
      arrow-up
      6
      ·
      7 hours ago

      I would also add that usually i will be used inside the code block to index locations within whatever data structures need to be accessed. Keeping track of how many times the loop has run has more utility than just making sure something is repeated 10 times.