mercredi 1 juillet 2015

What does range(len(lst)) mean?

def sum_positive(lst):
number = 0
for num in range(len(lst)):
    if lst[num] >= 0:
        number += lst[num]
return number

Can someone please explain to me what is the purpose of range(len(lst))? And explain step-by-step the execution of the for statement?

Aucun commentaire:

Enregistrer un commentaire