- 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].

21st Apr 2022, 1:23 PM
Abdul Solomon
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()])
21st Apr 2022, 2:43 PM
Lothar
Lothar - avatar
+ 4
You can also use enumerate() up = [i for i,e in enumerate(input()) if e.isupper()] print(up)
21st Apr 2022, 4:07 PM
Simba
Simba - avatar
+ 1
Already solved Thanks 🙏🙏
21st Apr 2022, 1:49 PM
Abdul Solomon
+ 1
# just use ord() a = input('~> ') print([a.index(i)for i in a if 65<=ord(i)<=90])
21st Apr 2022, 2:13 PM
Ervis Meta
Ervis Meta - avatar