for item in list:
its obviously the one with fewer function calls.
If you want to get the index of items as you go use enumerate like this
for pos, item in enumerate(collection):
More Related Contents:
- Fastest way to check if a value exists in a list
- Get difference between two lists
- Python Sets vs Lists
- Are tuples more efficient than lists in Python?
- Replace values in list using Python [duplicate]
- Why is [] faster than list()?
- What is the time complexity of popping elements from list in Python?
- Python – How to check list monotonicity
- [] and {} vs list() and dict(), which is better?
- Why is tuple faster than list in Python?
- Complexity of list.index(x) in Python
- Python: get a dict from a list based on something inside the dict
- Most efficient way for a lookup/search in a huge list (python)
- Create random list of integers in Python
- Creating an empty list in Python
- Get difference between two lists with Unique Entries
- Is there a way to circumvent Python list.append() becoming progressively slower in a loop as the list grows?
- sum each value in a list of tuples
- Python List Indexing Efficiency
- Python: iterating over list vs over dict items efficiency
- First items in inner list efficiently as possible [duplicate]
- Length of longest word in a list
- deque.popleft() and list.pop(0). Is there performance difference?
- Most efficient way to build single-element list from string with or without spaces? [closed]
- How to name a file using a value in a list in a dictionary?
- Python copy a list of lists [duplicate]
- How can I find same values in a list and group together a new list?
- TypeError: ‘float’ object is not subscriptable
- How to subclass Python list without type problems?
- How can I turn a flat list into a 2D array in python?