>>> def f(lst, func):
... for i in range(len(lst)):
... if isinstance(lst[i], list):
... f(lst[i], func)
... else:
... lst[i] = func(lst[i])
... return lst
...
>>> lst = [1, [2, 3], [4, [5, 6]]]
>>>
>>> lst = f(lst, lambda x: 2 * x + 1)
>>> lst
[3, [5, 7], [9, [11, 13]]]
>>>