+ 1
∆BH∆Y Remove the while loop and it's good
1st Feb 2021, 1:19 PM
VRVivek
+ 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
A͢J - avatar
+ 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
Jordan Baldoceda - avatar