So I have this piece of code:
def check_if_mirror(ch_1, ch_2):
if len(ch_1) != len(ch_2):
return False
nb_car = len(ch_1)
i = 0
while i < nb_car:
if ch_1[i] != ch_2[nb_car-1-i]:
return False
i = i+1
return True
What I want to do is make this same function (which checks if two pieces of string are mirrored) with a for loop instead of a while loop. I made this code:
def check_if_mirror(ch_1, ch_2):
if len(ch_1) != len(ch_2):
return False
ch_1 = ch_1[::-1]
for i in ch_1:
if ch_1 == ch_2:
return True
return False
But the problem with this one is that it works completely fine without the for loop.