Apr-20-2020, 04:09 AM
sample_list = [8, 2, 3, 0, 7] print("Sample list: %s " % sample_list) def sum_list(lists): for x in lists: total = total + lists[x] return total print("Sum of all the number in the list: "), print(sum_list(sample_list)) raw_input("\nPress ENTER to exit")I was told to create a function that can sum up all the elements in a list and this is what I came up with.
It didn't work
Please help