I want to replace repeated instances of the \"*\" character within a string with a single instance of \"*\". For example if the string is \"*
\"*\"
\"*
how about a non regex way
def squeeze(char,s): while char*2 in s: s=s.replace(char*2,char) return s print(squeeze("*" , "AB***abc**def**AA***k"))
This returns AB*abc*def*AA*k
AB*abc*def*AA*k