Write a recursive function named get_palindromes (words) that takes a list of words as a parameter. The function should return a list of all the palindromes in the list. The function returns an empty list if there are no palindromes in the list or if the list is empty. For example, if the list is ["racecar", "hello". "noon", "goodbye"], the function should return ["racecar". "noon"]. A palindrome is a word that is spelled the same forwards and backwards. Note: The get_palindromes() function has to be recursive; you are not allowed to use loops to solve this problem. For example: Test Result words = ["racecar", "hello", "noon", "goodbye", "test", "aibohphobia'] ['racecar', 'noon", "aibohphobia"] print (get_palindromes (words)) print(get_palindromes ([])) print(get_palindromes (['this', 'is', 'test'])) Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) 1 | Precheck Check [] [] Next page

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
Question >
Not complete
Marked out of
1.50
Flag question
Previous page
Write a recursive function named get_palindromes (words) that takes a list of words as a parameter. The function should return a list of all the palindromes in the list. The function returns an
empty list if there are no palindromes in the list or if the list is empty. For example, if the list is ["racecar", "hello", "noon", "goodbye"], the function should return ["racecar", "noon"].
A palindrome is a word that is spelled the same forwards and backwards.
Note: The get_palindromes() function has to be recursive; you are not allowed to use loops to solve this problem.
For example:
Test
words = ["racecar", "hello", "noon", "goodbye", "test", 'aibohphobia'] ['racecar', 'noon', 'aibohphobia']
print (get_palindromes (words))
print (get_palindromes ([]))
print (get_palindromes (['this', 'is', 'test']))
Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %)
Result
Precheck Check
[]
[]
Next page
Transcribed Image Text:Question > Not complete Marked out of 1.50 Flag question Previous page Write a recursive function named get_palindromes (words) that takes a list of words as a parameter. The function should return a list of all the palindromes in the list. The function returns an empty list if there are no palindromes in the list or if the list is empty. For example, if the list is ["racecar", "hello", "noon", "goodbye"], the function should return ["racecar", "noon"]. A palindrome is a word that is spelled the same forwards and backwards. Note: The get_palindromes() function has to be recursive; you are not allowed to use loops to solve this problem. For example: Test words = ["racecar", "hello", "noon", "goodbye", "test", 'aibohphobia'] ['racecar', 'noon', 'aibohphobia'] print (get_palindromes (words)) print (get_palindromes ([])) print (get_palindromes (['this', 'is', 'test'])) Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Result Precheck Check [] [] Next page
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning