I used the following code to get the answer:
i = sum(range(1, 1001))
print(i)
It doesn't look like you need to use a loop to get a result.
I used the following code to get the answer:
i = sum(range(1, 1001))
print(i)
It doesn't look like you need to use a loop to get a result.
Excellent. The function
sum()is also running a loop under the hood to calculate that. But the goal of this article is not to learn how to sum numbers, it's to learn how to use iterations because they have a much wider use cases in coding. Thank you for contribution