selfteaching / selfteaching/selfteaching-python-camp

day05 如何按照从大到小排序呢?

Open
#6,046 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
151
Forks
875
PR merge metrics
No merged PRs in 30d

Description

下面是我自己写的代码,可以计算出每个单词的个数,但不知道怎么写按照从大到小排序了。
我看了其他人的代码基本上都是一步步出来的,看着代码能够理解,不过我希望能够使用下列字典推导式的代码一步写出来。请问在这个方法基础上怎么加入排序呢?

去掉符号、空格及将字母全部改成小写

text_a=text.replace(',','').replace('.','').replace('--','').replace('!','')
text_b=(text_a.lower()).split()
print(text_b)

在前一步基础上,使用字典统计各英文单词的个数

text_dict = {i:text_b.count(i) for i in text_b}
print(text_dict)

*停了好多个月重新开始学真是不容易啊,相当于从0再开始终于又有点回到入门的感觉了,这次哪怕进度慢一点也要坚持学到最后。给自己立个Flag,争取年底之前学完。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue contains the complete Python word-count snippet but names no repository file or test. Start by running the shown example and consulting Python's dictionary-sorting documentation; done means explaining how to produce descending-frequency output while respecting the requested concise approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.