How to count total uppercase letters in all list elements without converting to string

My data:

import pandas as pd
data = {'game': [1, 2], 'moves': [['D4', 'd5', 'NF4'],['d5', 'c6', 'Be4']]}
df = pd.DataFrame(data) 
| game |     moves    |
|------|--------------|
| 1    |[D4, d5, NF4]  |
| 2    |[d5, c6, Be4] |

For each row, I want to extract the number of uppercase letters in the first n elements of the list in the column ‘moves’. So far I have this solution:

count = []
for row in df.moves:
    count.append(sum(1 for elem in listToString(row[0:10]) if elem.isupper()))

This works, but I would prefer a solution which does not involve concatenating the string elements of the lists. Is there such a thing?

Output:

[3, 1]

Answer

Try this:

count = df['moves'].apply(lambda x: sum(1 for i in x[:10] for y in i if y.isupper())).tolist()

Output:

[3, 1]