Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

bracket balanced or not in python

def isBalanced(final_str):
    type_brackets = ['()', '{}', '[]']
    while any(x in final_str for x in type_brackets):
        for br in type_brackets:
            final_str = final_str.replace(br, '')
    return not final_str


string = "{[]{()}}"
print(string, "-", "Balanced"
      if isBalanced(string) else "Unbalanced")
Comment

PREVIOUS NEXT
Code Example
Python :: how to convert integer to binary string python 
Python :: how to take a column from dataset in python 
Python :: python bufferedreader 
Python :: creating new virtual environment in python 
Python :: get vowels from string python 
Python :: datetime from float python 
Python :: how to get the year and month in python 
Python :: csv download django 
Python :: how to run flask in port 80 
Python :: random letters generator python 
Python :: tkinter maximise window 
Python :: how to print class attributes in python 
Python :: get method in python 
Python :: python dict copy() 
Python :: Write byte data in file python 
Python :: remove string from list in python 
Python :: device gpu pytorch 
Python :: python add commas to list 
Python :: iterate through list python with index 
Python :: find average with sum and len in python 
Python :: python remove .0 
Python :: Python list files only in given directory 
Python :: stegano python 
Python :: dask read csv 
Python :: python random generator from list 
Python :: python bytes to string 
Python :: python scheduler 
Python :: django url with string parameter 
Python :: python index of lowest value in list 
Python :: python sqrt 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =