Capital Positions
Sometimes you need to quickly find special characters in a string, such as checking a code format or highlighting uppercase letters in a word. Write a function capitals that takes word and returns a list of the indices of all uppercase letters. Indices start from 0, as usual in Python.
Примеры
Ввод
"CodEwArs"Вывод
[0, 3, 5]Ввод
"abcdef"Вывод
[]Ввод
"ABC"Вывод
[0, 1, 2]Нужно реализовать
def capitals(word: str) -> list[int]:
Теги
stringslistsarray
Prijavite se za ogled zgodovine oddaj
PrijavaPrijavite se za uporabo mentorja UI
PrijavaVisible tests
1
Input
"CodEwArs"Expected
[0,3,5]2
Input
"abcdef"Expected
[]3
Input
"ABC"Expected
[0,1,2]4
Input
"Hello"Expected
[0]5
Input
""Expected
[]6
Input
"ab"Expected
[]Focus radio
Paused · SomaFM · Fluid