0% found this document useful (0 votes)
7 views2 pages

Palindrome Checker Implementation in Python

The document presents a Python implementation of a palindrome checker using stacks and queues. It includes a function that processes a string to determine if it is a palindrome by comparing characters from both a stack and a queue. The user is prompted to input a string, and the program outputs whether it is a palindrome or not.

Uploaded by

waghvrushali28
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Palindrome Checker Implementation in Python

The document presents a Python implementation of a palindrome checker using stacks and queues. It includes a function that processes a string to determine if it is a palindrome by comparing characters from both a stack and a queue. The user is prompted to input a string, and the program outputs whether it is a palindrome or not.

Uploaded by

waghvrushali28
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Group no.

22
84 Pingle Sanskruti Somnath
85 Wagh Vrushali Anil
86 Deshpande Shreya
87 Chandrashekhar Dhanapune Aatmaja Dilip

Implementation of Palindrome checker [stack and queues]


from collections import deque
def is_palindrome(string):
# Initialize stack and queue
stack = []
queue = deque()

# Convert to lowercase and ignore non-alphanumeric characters


for ch in string:
if [Link]():
ch = [Link]()
[Link](ch)
[Link](ch)

# Compare elements from stack and queue


while stack and queue:
if [Link]() != [Link]():
return False
return True
string = input("Enter a string: ")

if is_palindrome(string):
print("The given string is a Palindrome.")
else:
print("The given string is NOT a Palindrome.")

OUTPUT:

You might also like