Question: Given a list of strings, I need to produce a new string by combining all strings' first character. My solution:

```
def K(lst):
    if lst == []:
        return ""
    else:
        return lst[0][0] + K(lst[1:])

```

It works, but I'm sure that's not accumulative recursion.
I also tried to attempt this question by using accumulative recursion, but I couldn't figure out the correct solution.

```
def K(lst):
    acc = ""
    if lst == []:
        return acc
    else:
        acc = acc + lst[0][0]
        return K(lst[1:])

```

I don't know how to mutate `acc`.

Answer: 
I think this is what you are looking for: 

```
def K(lst, s=""):
    if lst == []: return s
    else:         return K(lst[1:], s+lst[0][0])

```

Although this has the structure of accumulative recursion, I am not sure the Python interpretor can actually convert this internally to accumulative recursion.
I would not expose the inner function:

```
def K(lst):
    def sub(lst, acc):
        if lst:
            return sub(lst[1:], acc + lst[0][0])
        return acc
    return sub(lst, "")

```

then

```
>>> print K(["abc","bcd","cde"])
abc

```

---

FWIW, there is a way to mimic what you were trying to do, but it is **bad style** and only works in Python 3 because it needs *nonlocal* :

```
def K(lst):
    acc = ""
    def sub(lst):
        if lst:
            nonlocal acc # Python3 only
            acc = acc + lst[0][0]
            return sub(lst[1:])
        return acc
    return sub(lst)

>>> print(K(["abc","bcd","cde"]))
abc

```