What `for x in y` hides from you

Starting a for loop in Python is easy. You just type for x in y and you're off. You iterate over a list, or a string, or a range, and Python politely hands you back one item at a time. No index variable and no bounds checks. Compared to i++ from C/C++ or forEach from JavaScript, Python's version just works . For a long time, I treated for x in y as just a syntax that meant "loop over this thing,"…