Python如何删除一段英语里长度小于3的单词和出现次数少于2次的单词
n = input()
s = n.split()
for i in s:
if len(i) < 3 and n.count(i) < 2:
del s[s.index(i)]
n = " ".join(s)
work_count = defaultdict(int)
for word in text.split():
if len(word) > 3:
work_count[word] += 1
words = [k for k, v in work_count.items() if v >= 2]
print(words)