read.cash Log in
@MyHero

Program 101: Reverse and Palindrome using Python This program reverse the word/string and check whether it's palindrome or not. Palindrome: a word or phrases that reads the same backward or forward. Example: anna and madam. Note: It will remove white spaces Live Demo: https://onlinegdb.com/h0De12KzpK Code: # Reverse and Palindrome using Python word = input ("Enter an word: ").replace(" ","") # Reverse Word revs=''.join(reversed(word)) print("\n----- Result -----") print("Reverse Word:", revs) # Palindrome Checker print("Palindrome Checker:") if(word==word[::-1]): print(word , "is a palindrome") else: print(word , "is not a palindrome")

3 comments

Log in to join in Reading is open to everyone. Replying needs an account.