while True: a=str.replace('00','1') print(str) b=a.replace('11','') print(str) if len(b)==len(str): break else: str=b print(str)