+ 1

Summing up Number

I want to add numbers in a list. Help. And thanks https://code.sololearn.com/cvq0FXdWG0ld/?ref=app

4th Aug 2018, 11:38 PM
Andrews Essilfie
2 Answers
+ 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)
5th Aug 2018, 12:08 AM
Ī™Ļ‰Ī¬Ī½Ī½Ī·Ļ‚ ĪœĻ…ĻƒĻ„Ī±ĪŗĪÆĪ“Ī·Ļ‚
Ī™Ļ‰Ī¬Ī½Ī½Ī·Ļ‚ ĪœĻ…ĻƒĻ„Ī±ĪŗĪÆĪ“Ī·Ļ‚ - avatar
+ 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)
4th Aug 2018, 11:56 PM
Ammar Moulla
Ammar Moulla - avatar