# Count words characters frequency in python dictionaries examples

Contents

## Count words characters frequency in python dictionaries

### Frequency:

Count words character frequency in python. Now we want to count the frequency of each word in our list. You have already seen that it is easy to process a list using a loop. Try saving and executing the following example. Remember that + = tells the program to do something at the end of the current variable.

### Python dictionaries:

Both strings and lists are ordered sequentially, which means that you can access their contents using an index, a number that starts at 0… If you have a stringed list, you can use a pair of indexes to use a particular string for the first time. List, and then a special character within that string. Study the examples given below.

## Write a python script to count the frequency of words in a file using dictionaries.

In this program, we will learn to find the frequency of words in a file using dictionaries.

### Algorithm to count word character’s frequency:

• Step 1. Start
• Step 2. Create a dictionary and assign it to d.
• Step 3. Take care, ece words in a file.
• Step 4. In for loop, Perform
• Step 5. If the condition is true, then make d[i]=1
• Step 6. Otherwise d[i]=d[i]+1
• Step 7. End

### Programs to count word frequency Code:

`d=dict()f=('cse','ece','cse','cse')for i in f:    if i not in d:        d[i]=1    else:        d[i]=d[i]+1print(d)`

Output:

{‘cse’: 3, ‘ece’: 1}

## Recommended Post:

Pramod Kumar Yadav is from Janakpur Dham, Nepal. He was born on December 23, 1994, and has one elder brother and two elder sisters. He completed his education at various schools and colleges in Nepal and completed a degree in Computer Science Engineering from MITS in Andhra Pradesh, India. Pramod has worked as the owner of RC Educational Foundation Pvt Ltd, a teacher, and an Educational Consultant, and is currently working as an Engineer and Digital Marketer.

## Best PYthon Course

Get More trending Courses