Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Palindrome
#1
Hi. I have simple program which checks if a string is a palindrome
def is_palindrome(i):
   if len(i) <= 1:
       return True
   else:
       if i[0] != i[len(i)-1]:
           return False
       else:
           return is_palindrome(i[1:len(i)-1])
print(is_palindrome("kajak"))
Unfortunately, when I write a word with a capital letter the result is "false". Please help. What to do and what to add to my code so that the same text in upper or lower case will be considered "True"?
Reply


Messages In This Thread
Simple Palindrome - by Inkanus - Nov-24-2020, 08:26 PM
RE: Simple Palindrome - by bowlofred - Nov-24-2020, 11:22 PM
RE: Simple Palindrome - by Inkanus - Nov-25-2020, 01:48 PM
RE: Simple Palindrome - by sandeep_ganga - Nov-25-2020, 02:21 PM
RE: Simple Palindrome - by perfringo - Nov-25-2020, 04:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Palindrome in Python - result always false RavCOder 13 6,685 Oct-16-2019, 01:38 PM
Last Post: perfringo
  Palindrome mp3909 3 4,219 Oct-18-2017, 01:54 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020