0
What is the code to sum of consecutive numbers
Take a number N as input and output the sum of all numbers from 1 to N(including N)
5 Answers
+ 8
Iwinosa Aguebor ,
there are some issues to fix. see my comments in your code:
N = int(input())
total = 0 # > better to use a new variable `total` instead of `N`
O=list(range()) # > range() needs to get at least 1 argument. you can use the input value `N` here
for i in o: # > variable `o` needs to be in upper case
N=i+ 1 # > we need to use : total = total + i
Print(N) # > print() has to be writren in lower case, argument should be `total` not `N`
+ 1
Got it..
N = int(input())
o=list(range(0,N+1))
e = 0
for i in o:
e+=i
print(e)
0
N = int(input())
print( sum(range(N+1)) )
print( sum(range(N),N) )
print( sum(range(N))+N )
- 1
This is my try
N = int(input())
O=list(range())
for i in o:
N=i+1
Print(N)