Coders Packet

The Longest word in a sentence using Python programming

By Shaik Jilani

To find the longest word and its length in a given sentence using the Python programming language.

Write a program to find the longest word in a sentence is our question.

Let us consider "I am doing an internship in a code speedy startup company" as an input.
Here we consider a letter as a count.
If the count increases, it says about the length of the word.
If space is present, then it is considered as count zero.
After space, if the letter is present, then it will start counting from count zero of the next word.
After completing the given sentence, the longest word and its size are print.
In the above input which, we have taken the longest word is the internship.
The size of the longest word is"10".
Input: I want to become a software developer.
Output: The longest word is the developer
The size of the longest word is 9.

Download Complete Code


No comments yet