I have a function called add_ten. I want to loop this function over a list.
I want to create a looper function and pass the list and the add_ten function to loop over as input
def add_ten(x):
y = x+10
print 'value of x is ' + str(x)
print 'value of y is ' + str(y)
def looper(list,func):
for i in list:
return func(i)
I call the looper function
looper([1,2],add_ten())
I get this error.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-27-6510e446c709> in <module>()
----> 1 looper([1,2],add_ten())
TypeError: add_ten() takes exactly 1 argument (0 given)
How do I create the looper function properly so that it takes the right arguments?