3 ms·
I always translate “for” in my head to: for each item x in... In python is pretty direct: “for x in a” translates for for every x in the collection a, do this
by dkersten 7y ago
I always translate “for” in my head to: for each item x in...
In python is pretty direct: “for x in a” translates for for every x in the collection a, do this code...
In C it’s a bit more abstract: “for (i=0; i<10; ++i)” for every i in the range starting at i=0, while it’s less than 10, incrementing... Basically the body establishes a set or collection and the for loop executed the loop body “for” every item in the collection.
Modern languages often use foreach or some other slightly more descriptive name.