+ 2

Please help

how can I add all integers in my array .. in python for example I have array= [1,2,3,4,5]

21st Feb 2018, 5:05 PM
Jashan Singh
Jashan Singh - avatar
6 Respuestas
+ 1
can I do it without loop ?
21st Feb 2018, 5:23 PM
Jashan Singh
Jashan Singh - avatar
+ 1
Yes a = [1,2,3,4,5] a = sum(a) print(a)
21st Feb 2018, 5:24 PM
Toni Isotalo
Toni Isotalo - avatar
+ 1
what if i want an input from user and then add those integers... it is showing error
21st Feb 2018, 5:26 PM
Jashan Singh
Jashan Singh - avatar
+ 1
It throws an error because you are not using an array.
21st Feb 2018, 5:29 PM
Toni Isotalo
Toni Isotalo - avatar
+ 1
array=list(int(input())) i=sum(array) print(i) it's not working
21st Feb 2018, 5:30 PM
Jashan Singh
Jashan Singh - avatar
0
Are trying use that in your Basic calculator code?
21st Feb 2018, 5:31 PM
Toni Isotalo
Toni Isotalo - avatar