我试图从一个字符串中删除特定数量的重复字母并显示该字符串。 例如,我有一个类似“sdfgsd sdfd jkhj dfg sdf”的字符串,我想从这个字符串中删除3次或更多次重复的字母,然后再次显示 我怎样才能做到这一点。这是我的代码:
chars = "abcdefghijklmnopqrstuvwxyz"
check_string = "aanbg sdfsd futy asdf sdferg gyıuy"
for char in chars:
count = check_string.count(char)
//3 and more than 3 times repeated letters removing from string
if count >= 3:
remove (char, count)
print("check_string")
这应该是有效的:
如果您想自己实现
^{pr2}$letter_occurrances
:相关问题 更多 >
编程相关推荐