Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need some help on writing this function in Python 3.6. The instructions are defined below, as well as restrictions. Any help or guidance is greatly
Need some help on writing this function in Python 3.6. The instructions are defined below, as well as restrictions. Any help or guidance is greatly appreciated!
Please provide assistance for completing this function. This program is being written in Python 3.6 A sample output to test that it is working is the string "go hang a salami, I'm a lasagna hog!" 1. def is palindxome(phrase): given a string named phrase, this function returns True if the string is a palindrome, and False otherwise (a) Function behavior: i. Given phrase, you must determine if the string is identical forwards and backwards, any non-letter characters like spaces and if we ignore upper/lowercase and punctuation ii. Adapt the loop from lecture, which assumes that the entered string is lower-case and does not contain non-letter characters ii. In each iteration of the loop you are adapting, you will need to write two more loops The first loop should increment j as long as index j in phrase is not a letter, we can determine if a single character is a letter by taking that letter and calling isalpha) on it, which will be True only if the character is a letter iv. The second loop should decrement (decrease) j as long as index j in phrase is not a letter v. Once the two loops have finished, you know that index i is a letter and index j is a letter. You can now compare them and perhaps make.adeision, or perhaps not. vi. Once you are sure the string is not a palindrome, you should return False. Once you are sure the string is a palindrome, return True You cannot use any function that removes or replaces characters from a string. We haven't learned these yet. i. i. You cannot use any function that reverses a string for you. ii. You should not assume that phrase is all lowercase. You can use the lowerO function to create a copy of phrase that is converted to all lowercaseStep 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