Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Project: Word Frequency Counter Objective:

Create a Python script that counts the frequency of words in a given text using dictionaries, conditional sentences, loops, and recursive functions.

Instructions:

  1. Create a function that takes a string of text as input.

  2. Use a dictionary to store the frequency of each word in the text.

  3. Use conditional sentences to handle special cases (e.g., empty input).

  4. Use loops to iterate over the words in the text.

  5. Use a recursive function to process the text and update the word frequency dictionary

This project demonstrates the following concepts:

.Dictionaries: A dictionary (frequency) is used to store the frequency of each word in the text.

.Conditional sentences: The script uses an if statement to handle the base case of empty input.

.Loops: The for loop is used to iterate over the items in the word frequency dictionary and print the word and its count.

.Recursive functions: The process_words() function is a recursive helper function that processes each word in the text. It updates the word frequency dictionary recursively until all words are processed.

The script takes a string of text as input, removes punctuation, converts it to lowercase, and splits it into words. It then uses a recursive function to process each word and update the word frequency dictionary. Finally, it prints the word frequency dictionary, showing each word and its count.