Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write easy and clean code for me. I just start to study python and no ide

ID: 3722504 • Letter: P

Question

Please write easy and clean code for me. I just start to study python and no idea what to write.

Exercise 6.3. A palindrome is a word that is spelled the same backward and forward, like "noon and "redivider". Recursively, a word is a palindrome if the first and last letters are the same and the middle is a palindrome The folloving are functions that take a string argument and return the first, last, and middle letters def first (word): return word[0] def last(word): return word-1] def mi ddle(word): return wordl1-1] We'll see how they work in Chapter 8. 1. Type these functions into a file named palindrome.py and test them out. What happens if you call mi ddle with a string with two letters? One letter? What about the empty string, which is written and contains no letters? 2. Write a function called is_palindrome that takes a string argument and returns True if it is a palindrome and False otherwise. Remember that you can use the built-in function len to check the length of a string. Solution: http://thinkpython2. com/ code/palindrome_ soln.py

Explanation / Answer

Solution1.

In all the cases middle function returns empty stings

Solution2:

We check if first and last letter are same and the substring excluding first and last character is palindrome or not.If both the conditions are true then the string is palindrome otherwise it is not a palindrome.
Condition:

Code:

chegg is not palindrome
bannana is not palindrome
noon is palindrome
redivider is palindrome

I hope I could answer your question.Further, If you have any doubt you can ask me.