dimanche 30 août 2020

why my compiler directly jumping to else statement without checking if statment?

class val_brac:
    def bracket(self,str1):
        l=len(str1)
        for i in range(l):
            # print(i)
            if str1[i] == str1[l-1-i]:
               continue
            else:
                return False
        return True
            

print(val_brac().bracket('{[()]}'))

this is my code..

it returning False every time and the loop is running only once

Aucun commentaire:

Enregistrer un commentaire