【发布时间】:2017-08-10 10:27:23
【问题描述】:
输出应该是给定输入的前 3 个字母,但即使在输入上使用了 strip 函数后,我也无法删除空格。 代码:
from collections import Counter
insider = input("Enter the input you wanna enter : ")
actual = insider.strip()
count = Counter()
for i in actual:
count[i]+=1
print(count.most_common(3))
输出:
Enter the input you wanna enter : is this the ral life or is it just fantasy
[(' ', 9), ('i', 5), ('s', 5)]
【问题讨论】:
标签: python python-3.x collections counter strip