interesting difference between C++ and Python, iterating