我有一个问题,我必须在Python(v3.4.1)中计算重复的单词并将它们放在一个句子中.我使用了计数器,但我不知道如何按以下顺序获取输出.输入是:
mysentence = As far as the laws of mathematics refer to reality they are not certain as far as they are certain they do not refer to reality
Run Code Online (Sandbox Code Playgroud)
我把它变成了一个列表并对其进行了排序
输出假设是这样的
"As" is repeated 1 time.
"are" is repeated 2 times.
"as" is repeated 3 times.
"certain" is repeated 2 times.
"do" is repeated 1 time.
"far" is repeated 2 times.
"laws" is repeated 1 time.
"mathematics" is repeated 1 time.
"not" is repeated 2 times.
"of" is repeated 1 …Run Code Online (Sandbox Code Playgroud)