I am currently learning Python and would like some clarification on the difference between iterative and recursive functions. I understand that recursive functions call themselves but I am not exactly sure how to define an iterative function.
For instance, I wrote this code
random_list = ['6', 'hello', '10', 'find', '7']
def sum_digits(string):
return sum(int(x) for x in string if x.isdigit())
print "Digits:", sum_digits(random_list)
I thought that this was an iterative function but after doing some research I am not sure. I need to know specifically because the next exercise asks me to write a version of the function that is recursive/iterative (depending on what my first function is).
Fcalls itself, either directly or by calling some other functions that eventually callF. Everything else is an iterative function. Simple as that.