0
Capital indexes
i am creating a function that find the index of capital letters in a string but this function instead of returning all the indexes of capital letters it return the index of the first capital letter and then it stops can any one help me with this? def capital_indexes(string): for index , char in enumerate(string): if char.isupper(): capital_indexes1 = [] capital_indexes1.append(index) return capital_indexes1 print(capital_indexes(input()))
2 Answers
+ 6
return [idx for idx, c in enumerate(string) if c.isupper()]
+ 1
ok worked with this
def capital_indexes(string):
capital_indexes1 = []
for index , char in enumerate(string):
if char.isupper():
capital_indexes1.append(index)
return capital_indexes1