0
How does this return no ouput?
How does this code return no output? indices = [] def capital_indexes(text): word = text for i in range (0, len(word)): if word[i] == word.isupper(): indices.append(i) return indices capital_indexes("hello")
2 Respostas
+ 1
you passed argument 'hello' that means word ='hello'
word[i] means a single character in the word ='hello' through iteration
word[i] == word.isupper() means you are comparing single character with whole word how this possible?
try this
if word[i].isupper():
indices.append(i)
capital_indexes('HeLlO')
print(indices)