Count Words
Write a function count_words that takes a string s and returns the number of words in it. There may be multiple spaces at the beginning, at the end, and between words. An empty string has no words. The split() method will help — it splits a string into words.
Примеры
Ввод
"hello world"Вывод
2Ввод
" one two three "Вывод
3Ввод
""Вывод
0Нужно реализовать
def count_words(s: str) -> int:
Теги
strings
Kirjaudu sisään nähdäksesi palautushistorian
Kirjaudu sisäänKirjaudu sisään käyttääksesi tekoälymentoria
Kirjaudu sisäänTests7
Visible tests
Piilotettu testi 7
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