fork download
  1. def group_check(s):
  2. while '()' in s or '{}' in s or '[]' in s:
  3. s=s.replace('()','')
  4. s=s.replace('{}','')
  5. s=s.replace('[]','')
  6. return len(s)==0
  7.  
  8.  
  9.  
  10. print(group_check("()"))
  11. print(group_check("({"))
  12. print(group_check("({}{}[])"))
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
True
False
True