Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python help. Will give a thumbs up for a working answer! Thank you! A s tring is a palindrome if it reads the same forward

Python help. Will give a thumbs up for a working answer! Thank you!

A string is a palindrome if it reads the same forward and backward. The words mom, dad, and noon, for instance, are all palindromes.

The problem is to write a program that prompts the user to enter a string and reports whether the string is a palindrome. One solution is to have the program check whether the first character in the string is the same as the last character. If so, then the program can check whether the second character is the same as the second-to-last character. This process continues until a mismatch is found or all the characters in the string are checked, except for the middle character if the string has an odd number of characters.

To implement this idea, you can use two variables, say low and high, to denote the position of two characters at the beginning and the end in a string s.

Write a function isPalindrome() that takes a string and return True if it is a palindrome, and False if not.

Write the main() function that takes the string from the user and passes it to the isPalindrome() function, then prints the appropriate message

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

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions