Q. Write a python program to check whether the given string is palindrome or not, using deque. (Hint : refer to algorithm 4.1)
Answer :-
string = input("Enter a string :- ") deque = [ ] for i in string : deque.append(i) length = len ( deque ) // 2 x = 1 for i in range (length ) : front_element = deque.pop(0) rear_element = deque.pop() if front_element != rear_element : x = 0 break if x == 0 : print("Not palindrome") else : print("Palindrome")
Thanks for your help 👍🙂
ReplyDeleteWelcome 😊😊😊
DeleteThanks
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )