Only index needed: enumerate or (x)range?
Only index needed: enumerate or (x)range? Question: If I want to use only the index within a loop, should I better use the range/xrange function in combination with len() a = [1,2,3] for i in xrange(len(a)): print i or enumerate? Even if I won’t use p at all? for i,p in enumerate(a): print i Asked …