0
Python for beginners - sum of consecutive numbers code problem
Help needed! I have no idea how to solve this and I’m getting tired and thinking of quitting. Codecademy is by far better than this app, but I like how it motivates me to do a little each day. Right now though I have no idea how to progress.
12 Respuestas
+ 5
Tina Hagar
I am glad you got a result to your query.
Here is another option for you to consider which shows some of the flexibility of Python
print(sum(range(int(input())+1)))
+ 1
Thanks!
+ 1
n = int(input())
x = 0
for i in range(n+1):
#this for will have values from 0 , if you want you can have i.e. eg : range(-2,2):
x += i
print(x)
0
Don't lose hope! I know the answer but I'm too tired :(
0
Well thats probably not a good response for me at this moment.
0
I have already studied C++, HTML, CSS, Java Script (which I hated haha), now I want to add Python. Maths is not my strong point either so I’m also doing a maths course.
0
Thanks! That is exactly what was messing with me haha.
0
Let it be known, that this was a difficult exam. However, the answer is here:
N = input()
X = 0
For i in range(N+1):
X += i
Print(X)