Write a Python function to sum all the numbers in a list


Introduction

Write a Python function to sum all the numbers in a list. I have used python 3.7 compiler for debugging purpose.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. def sum(numbers):
  2. total = 0
  3. for n in numbers:
  4. total += n
  5. return total
  6. print("Sum of numbers:")
  7. print(sum((10, 20, 30, 60, 70)))

Result

python language techstudy.org

     





Related Topics




Popular Posts