Coders Packet

Number of words using Python code

By S.Veera Dhana lakshmi

My project name is Number of words Python code ,this project is used to the user given the sentence and output gives the how many words in the given sentence.

My project name is Number of words using Python code.The code explanataion given below:

In this code, we define a function count_words() that takes a sentence as input and counts the number of words in it.

The function splits the sentence into words using the split() method, which splits the sentence based on whitespace. It returns the length of the resulting list of words using the len() function.

The user is prompted to enter a sentence. The code then calls the count_words() function with the input sentence and assigns the result to the variable word_count.

Finally, the program prints the number of words in the sentence.

You can run this code and input a sentence to get the number of words in it.

 

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by S.Veera Dhana lakshmi (21ME1A5453)

Download packets of source code on Coders Packet