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
Kirjaudu sisään nähdäksesi palautushistorian
Kirjaudu sisäänKirjaudu sisään käyttääksesi tekoälymentoria
Kirjaudu sisäänTests12
Visible tests
Piilotettu testi 7
Piilotettu testi 8
Piilotettu testi 9
Piilotettu testi 10
Piilotettu testi 11
Piilotettu testi 12
They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.
Focus radio
Paused · SomaFM · Fluid