0

Intro Python: Sum of Consecutive Numbers

N = int(input()) #your code goes here total = 0 for i in range(1,N+1): total = total + N print(total) It gives an output, just not the right one. What did I forget?

9th Jun 2023, 8:44 PM
Kelley Pfeiffer
Kelley Pfeiffer - avatar
3 Answers
+ 3
At the moment you add N time the number N to total. What you actually want to do is adding the number i to total instead of N
9th Jun 2023, 8:58 PM
Lisa
Lisa - avatar
0
Lisa â€ïžđŸ§ĄđŸ’›đŸ’š Thank you.
9th Jun 2023, 9:02 PM
Kelley Pfeiffer
Kelley Pfeiffer - avatar
0
Welcome! Great that you could fix your code! 👍
9th Jun 2023, 9:03 PM
Lisa
Lisa - avatar