In Question 3, I used the same set of codes but added an 'else' statement and my output was different 'True True True' instead of 'True True False'. Come someone explain why I had a different (wrong) output?
The code I used is...
def is_palindrome(string):for ii in range(len(string)):if string[ii] != string[-(ii+1)]:return Falseelse:return Truexx = 'cbbeaeacccdceedbdecdabbaddabbadcedbdeecdcccaeaebbc'yy = 'dabdcdbebddedcdcbbcecbbcdcdeddbebdcdbad'zz = 'ddbcbeebdbcdddeabbeccaeababaecceababaeaccebbaedddabdbeebcbdd'print(is_palindrome(xx), is_palindrome(yy), is_palindrome(zz))
Read more… (44 words)