Write a program in Python to check if a sequence is a Palindrome.

By ayush goel in 22 Sep 2023 | 04:13 pm
ayush goel

ayush goel

Student
Posts: 346
Member since: 21 Sep 2023

Write a program in Python to check if a sequence is a Palindrome.

22 Sep 2023 | 04:13 pm
0 Likes
divas goyal

divas goyal

Student
Posts: 453
Member since: 22 Sep 2023

def is_palindrome(seq):

    seq = seq.lower()  # Convert to lowercase for case-insensitive check

    return seq == seq[::-1]


sequence = "racecar"  # Replace with your sequence

if is_palindrome(sequence):

    print(f"{sequence} is a palindrome.")

else:

    print(f"{sequence} is not a palindrome.")


22 Sep 2023 | 06:20 pm
0 Likes

Report

Please describe about the report short and clearly.