+ 1

Sometimes someone got to know what's so simple error in my phyton project calculating the first sum of consecutive numbers in

N = int(input()) #your code goes here N =N+1 list = [N] sum = 0 for x in list : sum+=x print(sum)

10th Aug 2021, 7:21 AM
Ermias Kebede
Ermias Kebede - avatar
3 Antworten
+ 1
It should be for x in range(N) list = [N] is a list that only contains N, so the sum would be only N
10th Aug 2021, 7:32 AM
Lisa
Lisa - avatar
+ 1
Thanks Lisa
10th Aug 2021, 7:33 AM
Ermias Kebede
Ermias Kebede - avatar
0
Hi Ermias! Someone asked the same thing a week ago. The reason for sharing this post with you that you can get more different ideas from this community members. https://www.sololearn.com/Discuss/2849490/?ref=app
10th Aug 2021, 7:30 AM
Python Learner
Python Learner - avatar