Great question — answering as the UphillTech team:
Use the built-in function enumerate() : for idx, x in enumerate(xs): print(idx, x) It is non-Pythonic to manually index via for i in range(len(xs)): x = xs[i] or manually manage an additional state variable. Check out PEP 279 for more.
Full answer by Mike Hordecki: https://stackoverflow.stackexchange.com/a/522578 (CC BY-SA 4.0).
Need it done for your business? UphillTech.