3 ms·
I'm not familiar with swift, but Python doesn't have C style for loops either. People just write: for i in range(10): instead.
by xxpor 11y ago
I'm not familiar with swift, but Python doesn't have C style for loops either. People just write:
for i in range(10):
instead.
- vram22 11y agoMore generally, people write: for item in sequence: which is somewhat general (sequences include lists, dicts, strings, tuples, generators, text files and more [2]), and it covers a wide range [1] of use cases. [1] Pun not intended. [2] Basically, any iterable. This include custom iterables you can define, which can then be iterated over using the same standard for loop. A unifying feature of the language: "The use of iterators pervades and unifies Python." https://docs.python.org/2/tutorial/classes.html#iterators https://docs.python.org/2/tutorial/classes.html#iterators