TOPIC

Wrong 100%

adriano asked 1 year ago

def balance(inp):
    list = []
    for letter in inp:
        if letter == "(":
            list.append("(")
        if letter == ")":
            try:
                list.remove("(")
            except:
                list.append("incorrect")
                return list
    return list
inp = input()

if len(balance(inp)) == 0:
    print("correct")
else:
    print("incorrect")

Não consegui encontrar o motivo. Funcioou para os casos de teste

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.