Computer Science, asked by shruti13845, 6 months ago

write a program to input a sentence and print each word of the string along with its length in tabular form


plzz guys do not spam ​

Answers

Answered by jai696
3

\huge\red{\mid{\fbox{\tt{Using\: Python\: 3}}\mid}}

import re

from string import punctuation

def main(s):

print("Word", "Length")

for word in re.sub('['+punctuation+']', '', s).split():

word_len = len(word)

diff = abs(word_len - 5)

print(f"{word}{' ' * diff}{word_len}") if diff > 0 else print(word, len(word))

main((s := input("string: ")))

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions