Question
A palindrome is a word that reads the same forwards and backwards, such as civic, racecar, or Hannah. One way to construct strings of letters
A palindrome is a word that reads the same forwards and backwards, such as civic, racecar, or Hannah. One way to construct strings of letters that read the same forwards and backwards (which I hesitate to call palindromes since most are not even words) is to start with the empty string, '', and repeatedly add the same letter to the front and back, for example: '' 'nn' 'anna' 'hannah'. (To get a string of odd length, you start with a one-letter string.) Write Python code to produce (pseudo-)palindromes in this way. Have it so that it produces only palindromes of even length. (So, start with the empty string.) Use a while loop. Prompt for and input a letter at each iteration (which goes at both ends of the string generated so far). Enter an empty string (which counts as False) to stop.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started