Home / Python Tips Generated By ChatGPT / The enumerate() Function for Getting Index and Value in Python Retrieve both the index and the value when looping over a sequence. Source Code for index, value in enumerate(["apple", "banana", "cherry"]): print(f"{index}: {value}")