Wordiest Sentence

Imagine you need to quickly find which sentence in a list contains the most words. Write a function max_words that receives a list of sentences where words are separated by single spaces. Count the words in each sentence. Return the largest word count.

Примеры

Ввод
["alice and bob love leetcode", "i think so too", "this is great thanks very much"]
Вывод
6
Ввод
["please wait", "continue to fight", "continue to win"]
Вывод
3
Ввод
["one"]
Вывод
1

Нужно реализовать

def max_words(sentences: list[str]) -> int:

Теги

stringsarray
PostgreSQLv16
Entre para enviar

O resultado da execução do código aparecerá aqui

Visible tests
1
Input
["alice and bob love leetcode","i think so too","this is great thanks very much"]
Expected6
2
Input
["please wait","continue to fight","continue to win"]
Expected3
3
Input
["one"]
Expected1
4
Input
["a b c d e"]
Expected5
5
Input
[]
Expected0
6
Input
["x","y z"]
Expected2
Focus radio
Paused · SomaFM · Fluid