data = ['abcd', 'aaa', 'aabbcc', 'abc', 'abccba', 'aabbccddee']
filtered_data = []
for s in data:
counts = {}
for c in s:
counts[c] = counts.get(c, 0) + 1
max_count = max(counts.values())
if max_count <= len(s) / 2:
filtered_data.append(s)
print(filtered_data)
标签:count,编写程序,max,字符串,filtered,counts,data From: https://www.cnblogs.com/DF696/p/17207811.html