i want to return a list of the indexes of the capital letters in a word based on a "user_input" word. i tried the code with lot of words and it actually works except wih "TEsT", it returns [0, 1, 0] instead of [0, 1, 3] :\ What's wrong?
I actually just read the similar question here, the answer was using "enumerate" to get the tuple of (index, char) at the same time, and check if the character is capital case. But i still wanna know what's wrong with my code :)
def capital_indexes(string):
my_list = list(string)
one_list = []
for capital in my_list:
if capital.isupper():
capital_index = int(my_list.index(capital))
one_list.append(capital_index)
print(one_list)
#return(one_list)
return (one_list)
#capital_indexes("HeLlO")
user_input = str(input("Enter a word"))
capital_indexes(user_input)