lst = "(())()"
count = 0

for i in range(len(lst)):
    if lst[i] == "(":
        count += 1
    else:
        count -= 1

if count == 0:
    print("True")
else:
    print("False")

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: