+ 1

# End module project related doubt (sum of consecutive numbers)(python )

I have solve the project But i have doubts (question of the project is in the code itself) https://code.sololearn.com/cA24a1179A0A/?ref=app I have a doubt that can thus be solved using while loops, if yes then how? (Please don't give solutions but only suggestions)

1st Feb 2021, 12:57 PM
∆BH∆Y
8 Answers
+ 1
∆BH∆Y Remove the while loop and it's good
1st Feb 2021, 1:19 PM
VRVivek
1st Feb 2021, 1:18 PM
∆BH∆Y
+ 3
∆BH∆Y while True doesn't make sense here because it will run till infinite. Try this num = int(input()) sum = 0 while num > 0: sum += num num -= 1 print(sum)
1st Feb 2021, 1:36 PM
A͢J
+ 1
Thank you VRVivek and I Am AJ ! Was my try correct according to the lesson of the Lists of the New course Python for Beginners
1st Feb 2021, 1:42 PM
∆BH∆Y
+ 1
Well you got it right in the second attempt Pay more attention to the condition given for the loop and learn the control flow of loops
1st Feb 2021, 1:45 PM
VRVivek
0
Yes you can solve this question using while loops Use a variable I and increase I by 1 and then add
1st Feb 2021, 1:13 PM
VRVivek
0
∆BH∆Y or you can replace the for loop with while and remove the inner while
1st Feb 2021, 1:20 PM
VRVivek
0
try this. def Suma_numeros (limite): suma=0 nmro=0 Lista_numeros=[] while nmro<limite: Lista_numeros.append(nmro+1) nmro+=1 for i in Lista_numeros: suma+= i return suma N= int(input()) print(Suma_numeros(N))
19th Feb 2021, 7:10 PM
Jordan Baldoceda