Can someone help me with my queue? I think the stack works fine.
I just need the indexing of the queue or do I need to index the queue?

from string12 import *
from queue import *

def main():
    stack1 = Stack()
    queue = Queue()

    word = raw_input("Enter a word or number sequence to check for palidrom: ")

    l_case = word.lower()
    s_case = word.lower()

    pallist1 = []
    pallist2 = []
    print l_case
    print s_case
    
    index = 0
    while index < len(l_case):
        letter = l_case [index]
        stack1.push(letter)
        index +=1

    while not stack1.isEmpty():
        pallist1.append(stack1.pop())
    print pallist1

    indexs = 0
    while indexs > len(s_case):
        butter = s_case [index]
        queue.enqueue(butter)
        indexs +=1

    while not queue.isEmpty():
        pallist2.append(queue.dequeue())
    print pallist2

    string1 = "".join(pallist1)
    string2 = "".join(pallist2)

    print string1
    print string2
    
    if string1 == string2:
        print "Palindrome"
    else:
        print "No Palindrome"

main()
Attachments
class Queue:
    def __init__(self):
        self.items = []

    def isEmpty(self):
        return self.items == []

    def enqueue(self, item):
        self.items.insert(0,item)

    def dequeue(self):
        return self.items.pop()

    def size(self):
        return len(self.items)
class Stack:
    def __init__(self):
        self.items = []

    def isEmpty(self):
        return self.items == []

    def push(self, item):
        self.items.append(item)

    def pop(self):
        return self.items.pop()

    def peek(self):
        return self.items[len(self.items)-1]

    def size(self):
        return len(self.items)

You only need to check if reversed string equals the normal one. To use stack and queue you can do comparision until first failure during reading back. Should not take more than 10 lines of code.

If you can not use a built-in method to reverse the string (or list if you prefer), please state what the requirements are, otherwise:
reverse_word = input_word[::-1] ## [begin:end:step=-1]

Edited 5 Years Ago by woooee: n/a

This question has already been answered. Start a new discussion instead.