- 1
Help me in this using python
Write a function named capital_indexes. The function takes a single parameter, which is a string. Your function should return a list of all the indexes in the string that have capital letters. For example, calling capital_indexes("HeLlO") should return the list [0, 2, 4].
5 Answers
+ 5
Abdul Solomon ,
it is also possible to use the string method .isupper():
txt = input()
print([txt.index(char) for char in txt if char.isupper()])
+ 4
You can also use enumerate()
up = [i for i,e in enumerate(input()) if e.isupper()]
print(up)
+ 1
Already solved
Thanks đđ
+ 1
# just use ord()
a = input('~> ')
print([a.index(i)for i in a if 65<=ord(i)<=90])