str=")(hi)(hello))" lcount=0 rcount=0 for i in str: print(i) if i == "(": lcount+=1 if i == ")": rcount+=1