+ 1
Is there a way to add All the numbers in an array
I want write a script that can add all the number so in an array Array = [ 1, 2, 3, 4, 7, 9]
4 Respostas
+ 3
print(sum(array))
+ 2
I think this code will do what you want.
https://code.sololearn.com/cvi8veJ9CxlB/?ref=app
+ 1
Look into List Comprehension... It allows you to make a list with whatever, on the fly.. For Example...
Numbers = [I for I in range(100)]
That above code would create an array called numbers and give it [0,1,2,3,4,5,etc] ... You can even change the parameters...
oddNumbers=[i for i in range(100) if i%2!=0]
Here is a code I wrote with examples of different uses...
https://code.sololearn.com/c195fjflDL5F/?ref=app
0
Thanks Maias Alakramy exactly what I was looking for