Saturday, 15 February 2014

Python. Making a function that tests if a word is a palindrome recursively -


I am trying to create a program that tests if a word is a palindrome using a recursive function It's a lot of work to do, but I'm having trouble carrying it to the next letter if the first and the last are the same.

  word = input ("password") word = word. DRTTPindrome (term): if lane (word) == 1 or lane (word) == 0: return 0; If the word [0] == word [-1]: print (word [0], word [-1]) pylandrome (word); Others: return 1; Test = palindrom (word) if test == 0: print ("yes") elif test == 1: print ("no")  

so it now checks that the first and the last The letters are the same and if so, then the function should run again. I want this when the word [1] and the word [2] check, but I am having trouble, I tried the splitting word and tried to capitalize only the letters, but this is the length of 1 to the list Was looking. So if there is a way to get the length of the whole divided list, then it will also work.

When you call your method again and again, you just remember the return statement. Are:


No comments:

Post a Comment