Nov-22-2019, 11:34 AM
(Nov-21-2019, 12:08 PM)ThomasL Wrote: Your function is working but you need to call it with your list to get a result.
And beware not to name a variable "sum" as this is an inbuild python function
actually the one that does what you rebuild.
def sum_list(elements): total = 0 for element in elements: total += element return total broken_prices = [5, 3, 4, 5, 4] + [4] print(sum_list(broken_prices)) # ==> 25 print(sum(broken_prices))
Thank you ThomasL and Auggie. This is exactly what I was trying to do! I find the element aspect of things a bit confusing, so I appreciate the help.
Thanks to everyone else who gave input. Sorry if I misplaced this. I wasn't sure if this should go in 'Homework' since this wasn't really homework, but rather something I was just trying to do on my own with code I used elsewhere.