I am trying to get the indices of capital letters (including special ones) in a line. I found here the following solution:
[i for i, c in enumerate(s) if c.isupper()]
However, this does not work for letters like: Ö, Ä
and Ü
:
I tried therefore:
[re.search(r'^([^A-ZÄÖÜ]*[A-ZÄÖÜ]){i}',s).span()[1] for i in range (1,y)]
where y is the number of capital letters in s
.
The second solution works if I define i
, but under the loop, it returns:
attributeerror 'nonetype' object has no attribute 'span'.
How can I solve it in an efficient way?