9 Answers
+ 1
I tried this
N = int(input())
#your code goes here
sum = 0
for i in range(1, N+1):
sum += i
print(sum)
But it still shows me the list instead of the last value, I tried indexing it but since it is an integer I am getting an error message
0
Post your attempt first
0
N = int(input())
#your code goes here
for N in range(0, N+1):
print(N + N)
0
//Here is an example
l = [1, 3, 4, 5]
sum = 0
for i in l:
sum += i
print(sum)
0
Thank you š
0
t=0#declaring variable and assign initial value zero to it
for e in range(1,5):
# calculate values from 1 to 4
t+=e
# adding t and e
print(t)
0
No in the above code you will put print(sum) inside for loop but you will put it outside for loop. just run this below code then it will give output
https://code.sololearn.com/cPE8igoIzUBH/?ref=app
0
N = int(input())
t=0
for e in range(0,N+1):
t+=e
print(t)
- 1
N = int(input())
count = N
x = range(1, N +1)
for i in x:
N = i + N
print(N - count)