Which Python built-in function can be used to iterate over a sequence while also obtaining the index of the current item?

  • enumerate()
  • for_each()
  • index()
  • iterate()

The enumerate() function in Python is used to iterate over a sequence (like a list or tuple) while also obtaining the index of the current item. It returns pairs of index and value, making it helpful for certain looping scenarios.

Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *