Question: Python recursion problem 4. Write a recursive function recFloatCount() that takes a one-dimensional list of strings as a parameter and returns the count floats that
Python recursion problem
4. Write a recursive function recFloatCount() that takes a one-dimensional list of strings as a parameter and returns the count floats that are found in the list. Recall that you can determine whether an item is an int or float by writing type(item) == int, type(item)==float. The only list functions you are allowed to use are len(), indexing (Ist[i] for an integer i), or slicing (Ist[i:]] for integers i and j). In particular, the function should not in any way alter the list passed as a parameter. The following shows several sample runs of the function. You should test with other inputs as well.: >>> print (recFloatCounter (['c','a','t',' ,1.0,'h',1, 'a',2,'t' ,100.2])) 2 >>> print (recFloatCounter(['c',4,8.2, 'a',1,'t',20,5.5])) 2 >>> print (recFloatCounter ([])) 0 >>> print (recFloatCounter(['c','a','t'])) 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
