Top.Mail.Ru
Ответы

Количество слов в строке. Python. Решить через классы.

По дате
По рейтингу
Аватар пользователя
Гений

class Text:
def __init__(self, txt):
self.txt = txt

def words(self):
return [word for word in self.txt.split(' ') if word]

def words_qty(self):
return len(self.words())

print(Text(input()).words_qty())