Python Forum
Palindrome program - I can't figure it out.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Palindrome program - I can't figure it out.
#1
from string import ascii_letters, digits

s = open("saxo.txt").read()
s = s.lower()
s = "".join([c for c in s if c in ascii_letters or c in digits])

def is_palindrome(s):
    if len(ascii_letters) >=7 and ascii_letters== ascii_letters[::-1]:
        return ascii_letters
    
print(is_palindrome(s))
# I want to create a program that computes all palindromic substrings of length ≥ 7 from the file.
# But somehow I can't make it work. I'm new to Python
Reply


Messages In This Thread
Palindrome program - I can't figure it out. - by Gabar112 - Feb-18-2018, 12:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Program to check whether a number is palindrome or not PythonBoy 18 2,790 Sep-12-2023, 09:27 AM
Last Post: PythonBoy
  Palindrome checker case sensive edwdas 3 2,667 Nov-07-2019, 05:57 PM
Last Post: nilamo
  Palindrome.strip pirts.emordnilaP RodNintendeaux 4 3,882 Oct-08-2017, 02:30 AM
Last Post: RodNintendeaux

Forum Jump:

User Panel Messages

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