0
Python - Paréntesis Equilibrados - No me funcionó el último caso de prueba de esa práctica ayuda
if __name__ == '__main__': cadena = [x for x in input() if x in "{}[]()"] if len(cadena) % 2 != 0 or len(cadena) == 0: respuesta = "False" else: abierto=0 cerrado=0 for a in cadena: if a=="(": abierto+=1 else: cerrado+=1 if abierto==cerrado: respuesta="True" else: respuesta="False" print(respuesta) https://code.sololearn.com/cOhyQfO0KAT5/?ref=app
2 Antworten
- 1
code is working perfectly
I'm not fluent in Spanish but the thing i understood is you need to check the parenthesis which the given string is closed or not
but this only work for "( )"
0
You are right that is what my code does and I do better I have to expand the others "() {} []". Thank you very much.