def palindrome(string): for i in range(0, int(len(string) / 2)): if string[i].lower() == string[-i - 1].lower(): continue else: return False return True
- def palindrome(string):
middle = int(len(string) / 2)is_palindrome = Falsefor i in range(0, middle):- for i in range(0, int(len(string) / 2)):
- if string[i].lower() == string[-i - 1].lower():
is_palindrome = True- continue
- else:
is_palindrome = Falsereturn is_palindrome- return False
- return True
test.assert_equals(palindrome('bab'), True) test.assert_equals(palindrome('aaAAaa'), True) test.assert_equals(palindrome('abcCBA'), True) test.assert_equals(palindrome('123123asdasd'), False)
- test.assert_equals(palindrome('bab'), True)
- test.assert_equals(palindrome('aaAAaa'), True)
test.assert_equals(palindrome('abcCAB'), True)- test.assert_equals(palindrome('abcCBA'), True)
- test.assert_equals(palindrome('123123asdasd'), False)