Код: Выделить всё
[['How', 3], ['are', 3], ['you', 3], ['today', 5]]
def char(s):
Код: Выделить всё
l = [] # list for holding your result
# convert string s into a list of 2-element-lists
s = text.split()
s = [[word ,len(word)] for word in s.split()]
print("Output:\n", s)
print()
return l
text = "How are you today"
l = char(text)
print()
Код: Выделить всё
[['How', 17], ['are', 17], ['you', 17], ['today', 17]]
Подробнее здесь: https://stackoverflow.com/questions/425 ... -each-word