selfteaching / selfteaching/selfteaching-python-camp

Day05用循环方式统计字符串内每个单词出现的次数

Open
#4,442 1 comment 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

图片
@seven_tears张教练,用字典统计字符串内每个单词的个数,我的思路是用分割函数得到单词列表后,遍历单词列表,内嵌一个for循环遍历字典内的key,用key与每个单词比较,如果key与单词相同,key对应的值就加一,如果不同则赋值为一,并把键值对新增到字典内,最后再对字典进行打印。但我这样写,最后打印出来的是没经过处理的字典,我想应该是if语句那里出错了,但找不到具体原因

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

Review the Day05 exercise and the code shown in the attached image, starting with the split word list, dictionary keys, and nested loop conditions. Reproduce the result, identify why the dictionary is not updated as intended, and confirm that the final output contains the correct count for every word.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.