Something that should be very simple and yet I am not able to solve it. The indexing does not appear correctly when a character duplicates: For example:
list=[]
stringg="BAtmAn"
for i in stringg:
if i.isupper():
list.append(stringg.index(i))
print(list)
And the output shows [0,1,1] instead of [0,1,4].
When the stringg variable is changed to "BAtmEn" it appears the way I expect it to appear in the first example.
indexreturns the index of the first match unless you provide a start.enumerateinstead. Examplefor index,letter in enumerate(stringg): if letter.isupper(): lst.append(index)listas a variable name as it will conflict with the built inlistclass.