Use enumerate(iterable) in loops to access both index and value, e.g., for i, val in enumerate(my_list): for concise iteration.
Pass a start parameter to adjust index numbers, e.g., enumerate(my_list, start=1) starts indexing from 1 instead of 0.
Unpack index and item directly in the loop using for index, item in enumerate(iterable): for cleaner, more readable code.
Use enumerate() to avoid managing a separate index variable, simplifying code for both performance and clarity.
Works with lists, tuples, strings, dictionaries (keys or values), and even custom generators, ensuring versatility.
Combine enumerate() with list comprehensions for generating indexed transformations, e.g., [(i, x*2) for i, x in enumerate(my_list)].