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")

14th Nov 2021, 10:56 AM
Shedrick Williams
Shedrick Williams - avatar
2 Answers
+ 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)
14th Nov 2021, 12:59 PM
Krishnam Raju M
Krishnam Raju M - avatar