Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python function isPalindrome() that checks whether a passed string is palindrome or not. If the parameter string is a palindrome, then the function

image text in transcribed

Write a Python function isPalindrome() that checks whether a passed string is palindrome or not. If the parameter string is a palindrome, then the function will return True, otherwise it will return False. A palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g., "madam" or "nurses run" or "Madam I'm Adam!" or "Was it a cat I saw?". The function can check if given string is a palindrome or not, by following the steps given below: 1. Create a new string that only contains the alphanumeric characters, i.e. skip the other characters. E.g.: From string "Madam I'm Adam!", create a new string "MadamImAdam". 2. Convert this new string to upper case. Eg: from "MadamImAdam", get "MADAMIMADAM". 3. Compare with its reverse. If the new string is equal to its reverse, then return True, otherwise return False. Write Python statement that reads a string, call the function and print an appropriate message. Part 2: Please enter a string: A man, a plan, a canal, Panama! The string 'A man, a plan, a canal, Panama!' is a palindrome. Part 2: Please enter a string: Good work The string 'Good work' is not a palindrome

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Why did you leave your last job?

Answered: 1 week ago

Question

sharing of non-material benefits such as time and affection;

Answered: 1 week ago