Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7552661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:50:16+00:00 2026-05-30T10:50:16+00:00

I have a piece of text and I have created a dictionary in python.

  • 0

I have a piece of text and I have created a dictionary in python. It has words as keys, and the number of times the words has occurred in the text as values. This dictionary is sorted in decreasing value of the values field. Here is a snippet of my list:

[('the\n', 1644), ('and\n', 872), ('to\n', 729), ('a\n', 632), ('she\n', 541), 
('it\n', 530), ('of\n', 514), ('said\n', 462), ('i\n', 410), ('alice\n', 386),
('in\n', 369), ('you\n', 365), ('was\n', 357), ('that\n', 280), ('as\n', 263), 
('her\n', 248), ('at\n', 212), ('on\n', 193), ('all\n', 182), ('with\n', 181),
('had\n', 178), ('but\n', 170), ('for\n', 153), ('so\n', 151), ('be\n', 148), 
('not\n', 145), ('very\n', 144), ('what\n', 136), ('this\n', 134),
('they\n', 130), ('little\n', 128), ('he\n', 120), ('out\n', 117),
('is\n', 108), ... ]

I want to print the 25 most frequent words. that is fairly simple and I have done it. The next part is to print the 25 most frequent words starting with the letter “f”. How do I find this and append it to the list of 25 most frequent words?

Also, I have to add a rank of all the words. For example, in my dictionary, “the” will be ranked 1, “and” 2 and so on. How do I add a rank to the list of words?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:50:18+00:00Added an answer on May 30, 2026 at 10:50 am

    Just filter using a list comprehension:

    f_words = [(word, freq) for (word, freq) in the_list if word.startswith('f')]
    

    Since the original list is sorted, so will this one be. You can then just slice it to get the top 25: f_words[:25]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code: function func1(text) { var pattern = /([\s\S]*?)(\<\?(?:attrib |if
Hey guys, I have this piece of jquery code: <script type=text/javascript > $(function() {
I have this piece of code. I want to remove the rows created with
I have a piece of text, that I wish to show truncated, but when
Basically, I have an array of keywords, and a piece of text. I am
I have this piece of code (summarized)... AnsiString working(AnsiString format,...) { va_list argptr; AnsiString
I have a piece of XML that is structured similar to this: <root> <score
I have this piece of Javascript and it just won't work. I allready checked
I have a piece of C# code that add the values of an enum
I have a created text file in unix enviroment using java code. For writing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.