I have this function that receives a word and lists the index of each capital letter:
def capitals(word):
print word
lst = []
for i in word:
if i.isupper():
lst += [word.index(i)]
return lst
When all capital letters in word are different, it runs fine. Example:
capitals("AuIkkdjsiP") returns [0,2,9]
However, if a string has duplicate capitals, this happens:
capitals("AuAskdjfIsjUsdhA") returns [0,0,10,0]
How do I get the index of the other occurrences of the char "A" when iterating the string?