You are viewing a single comment's thread. Return to all comments →
s=input() l=[] for i in s: if not l: l.append(i) else: if(l[-1])==i: l.pop() else: l.append(i) if not l: print("empty string") else: print(''.join(l))
Seems like cookies are disabled on this browser, please enable them to open this website
Super Reduced String
You are viewing a single comment's thread. Return to all comments →
s=input() l=[] for i in s: if not l: l.append(i) else: if(l[-1])==i: l.pop() else: l.append(i) if not l: print("empty string") else: print(''.join(l))