小弟最近在做PYTHON习题
Problem
Given: A string ss of length at most 10000 letters.
Return: The number of occurrences of each word in ss, where words are
separated by spaces. Words are case-sensitive, and the lines in the output
can be in any order.
Sample Dataset:
We tried list and we tried dicts also we tried Zen
Sample Output:
and 1
We 1
tried 3
dicts 1
list 1
we 2
also 1
Zen 1
但是小弟做同样练习时会重复出现有重复的字:
we 3
作者: wennie0433 2017-08-23 11:19:00
word那个回圈每次都会重制你的pare所以根本没纪录到循环外面宣告一个dup = dict()然后dup.update(pare)最后那个循环就直接搬出来不要在循环里面pare换成dup然后他题目大小写应该市分开算lower()要拿掉