Python program to accept sentence from user and display the longest word of that sentence

#longest word of the sentence with its length
sent=input("Enter sentence : ")
words=sent.split()
length=len(words[0])
for word in words:
if length < len(word):
longest=word
length=len(word)
print("The longest word is", longest, " and its length is ",length)

Expected Output:
Enter sentence : 'Developer of C++ language is Bjarne Stroustroup'
('The longest word is', 'Stroustroup', ' and its length is ', 11)

Leave a Reply