'Why does the palindrome function built on top of the Deque class doesn't work?
I created the following palindrome function using a Deque class. The program should return True and False. However, nothing is returned when I run the program. Can anyone ascertain why?
class Deque:
def __init__(self):
self.items = []
def add_front(self, item):
self.items.insert(0, item)
def add_rear(self, item):
self.items.append(item)
def palindrome(word):
lst1 = Deque()
lst2 = Deque()
[lst1.add_front(i) for i in word.lower()]
[lst2.add_rear(i) for i in word.lower()]
return lst1.items == lst2.items
palindrome('racecar')
palindrome('oranges')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
