+ 1
Summing up Number
I want to add numbers in a list. Help. And thanks https://code.sololearn.com/cvq0FXdWG0ld/?ref=app
2 ответов
+ 1
digits = [1,2,3,4,5,6,7,8,9,0]
sum=0
for d in digits: #using for loop
sum+=d
print(sum)
sum=0
d=0
while d<len(digits): #using while loop
sum+=digits[d]
d+=1
print(sum)
+ 4
use
insert function
for example:
digits=[1,2,3]
index=0
digits.insert(index,2)
print(digits)
[2,1,2,3]
result:add 2 in index(0)