how to get index in foreach loop python code example Example: get index in foreach py for idx, val in enumerate(ints): print(idx, val)