Answers for "add all elements in list python"

33

how to calculate the sum of a list in python

# Python code to demonstrate the working of  
# sum() 
numbers = [1,2,3,4,5,1,4,5] 
  
# start parameter is not provided 
Sum = sum(numbers) 
print(Sum) # result is 25  
# start = 10 
Sum = sum(numbers, 10) 
print(Sum) # result is 10 +25 = 35
Posted by: Guest on May-25-2020
16

python sum of list

>>> list = [1, 2, 3]
>>> sum(list)
6
Posted by: Guest on January-27-2020
1

add one to all elements in list python

new_list = [x+1 for x in my_list]
Posted by: Guest on March-12-2021
1

python add all values of another list

a = [1, 2, 3]
b = [4, 5, 6]
a += b
# another way: a.extend(b)
Posted by: Guest on February-03-2020

Code answers related to "add all elements in list python"

Python Answers by Framework

Browse Popular Code Answers by Language