S
s99999999s2003
hi
my friend has written a loop like this
cnt = 0
files = [a,b,c,d]
while cnt < len(files) :
do_something(files[cnt])
i told him using
for fi in files:
do_something(fi)
is better, because the while loop method makes another call to
len..which is slower..
am i partly right? or is there a better explanation for using the for
method.?
thanks
my friend has written a loop like this
cnt = 0
files = [a,b,c,d]
while cnt < len(files) :
do_something(files[cnt])
i told him using
for fi in files:
do_something(fi)
is better, because the while loop method makes another call to
len..which is slower..
am i partly right? or is there a better explanation for using the for
method.?
thanks