2 ms·
Seeing `for i in range(len(lst)): lst[i]...` gives me hives. That's cool if you're wanting to be super explicit about how the indexing works, but in this page i
by kstrauser 7y ago
Seeing `for i in range(len(lst)): lst[i]...` gives me hives. That's cool if you're wanting to be super explicit about how the indexing works, but in this page it goes on to say "or you can just write sum(lst)" without worrying about the indexing.
I would write the explanations like:
result = 1
x = [1, 2, 3, 4, 5]
for number in x:
result = result * number
print(result)
which in my opinion is much closer to the way a mathematician would think about the process.