fork download
  1. def sum_list(numbers):
  2. """
  3. This function takes a list of integers and returns their sum.
  4.  
  5. Args:
  6. numbers: A list of integers.
  7.  
  8. Returns:
  9. The sum of the integers in the list.
  10. """
  11. total = 0
  12. for number in numbers:
  13. total += number
  14. return total
  15.  
  16. # Example usage:
  17. my_list = [1, 2, 3, 4, 5]
  18. list_sum = sum_list(my_list)
  19. print(f"The sum of the list is: {list_sum}")
Success #stdin #stdout 0.03s 9640KB
stdin
Standard input is empty
stdout
The sum of the list is: 15