Question: . [Debugging Palindrome; 10pt] Your friend has written a program called palindrome(s), which is supposed to check whether a string s is a palindrome (reads
. [Debugging Palindrome; 10pt] Your friend has written a program called palindrome(s), which is supposed to check whether a string s is a palindrome (reads the same forwards and backwards, like eve, or racecar). The idea is simple: words of length at most 1 are palindromes, for longer words you check that the i-th letter from the front is the same as the i-th letter from the back of the word. The code written by your friend isnt working at all:
def palindrome(s):
if len(s) <= l:
return True
for i in range(s):
if s[i] == s[len(s)-i]:
return True
return True
Copy and paste the code into your program window You may use the debugger to fix this code. Comment on each error you found (there are four errors): how you found it, what the error was, and how you fixed it. Note, you can do this by using comments in the line of code you fixed. A significant part of the credit for this problem will be for documenting the errors you found, so just fixing the program will not get you full credit. Do NOT change the code by using different constructs, such as the reverse(string) method. Here is a test-run of how the fixed program should work:
>>> palindrome('eve')
True
>>> palindrome('evelyn')
False
>>> palindrome('e')
True
>>> palindrome('kayak')
True
>>> palindrome('kayaks')
False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
