How do I add together integers in a list (sum a list of numbers) in python?
x = [2, 4, 7, 12, 3] sum_of_all_numbers= sum(x) or you can try this: x = [2, 4, 7, 12, 3] sum_of_all_numbers= reduce(lambda q,p: p+q, x) Reduce is a way to perform a function cumulatively on every element of a list. It can perform any function, so if you define your own modulus function, it … Read more