Intro Python: Sum of Consecutive Numbers | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
+ 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