I have a list of strings consisting of integers, and I am trying to replace them with the sum of their digits. E.g. `nums = ["12","23","33"]` -> `nums = [3,5,6]`

Here is my code:

```
strng = ['12','23','33']

for i in range(len(strng)):
    print(list((map(lambda x:int[x],list(strng[i])))))

```

For the above I am getting a `TypeError: 'type' object is not subscriptable`. It works up until map(), but when I add the list(map(...)), I get this error.

Any ideas how to fix it?

My after this is fixed, my idea is to do the following:

strng = ['12','23','33']

```
for i in range(len(strng)):
    strng[i] = sum(list((map(lambda x:int[x],list(strng[i]))))))

```

Which should replace each of strng with the sum of its digits.
['https://Stackoverflow.com/questions/68807437', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/16510721/']
The error you're getting is you because you wrote `int[x]` instead of `int(x)`. However, there are some additional issues with your existing solution.

The short and pythonic solution to this problem would be:

```py
answer = [sum(map(int, list(s))) for s in strng]

```

To break this down:

1. `[... for s in strng]`: this is a [list comprehension](https://www.w3schools.com/python/python_lists_comprehension.asp)
2. `list(s)`: This takes each string and converts it into a list of str of each character, so `"123"` becomes `["1","2","3"]`
3. `map(int, list(s))`: This applys the int conversion to each element in `list(s)`, so `["1","2","3"]` becomes `[1,2,3]`
4. `sum(...)`: We take the sum of the resulting list of ints

The equivalent of the above using a normal for loop would be something like this:

```py
answer = []
for s in strng:
    list_of_chars = list(s)
    list_of_ints = map(int, list_of_chars)
    sum_of_ints = sum(list_of_ints)
    answer.append(sum_of_ints)

```
Not really efficient, but try this :

```
strng = ['12','23','33']

def function(strng) :
    my_list = []
    for string in strng :
        my_list.append(0)
        for digit in string :
            my_list[-1] += int(digit)
    return my_list

strng = function(strng)
print(strng)

```