Welcome to the Treehouse Community
Looking to learn something new?
Luke Telford2,931 Points
How to use for loop?
I can't wrap my head around this, in the challenge it says to sue a for loop to run both these functions but i don't remember anything being said about for loops during this course. How do I go about doing this?
this is how you want to do it.
def add_list(mylist): total = 0 for num in mylist: total = total + num return total
You pass a list to the function for example my_list = [1,2,3] which should return 6 when the function add_list() is called.