Question: task is to write a program that either says 'yes' this sequence is a palindrome or 'no' it is not. What to do Write a

task is to write a program that either says 'yes' this sequence is a palindrome or 'no' it is not.

What to do

Write a program that takes in a sequence of n-integers as input, and uses a recursive sub-routine to determine if the sequence of integers is a palindrome or not. Solutions that do not utilize a recursive sub-routine will not receive credit.

Hint: Remember a base case tells you when to stop recursing. Sometimes there are multiple triggers to stop, and thus multiple base cases. If you are stuck, try programming this iteratively with a loop first, then transforming it into a recursive solution.

EXPECTED INPUT You can assume the person using your program will only give good input (meaning they won't screw up and enter something like: "3, 5, $.56, oops". Allow the user to terminate giving input by entering a -1 (and make sure that -1 doesn't get included as a part of your number sequence)

EXPECTED OUTPUT The program should output the sequence of numbers, and a message showing the result of the palindrome analysis.

#follow the skeleton code and write the code where instructed.

from math import * # may or may not choose to use math library subroutines


def getInput(list):
print("Hello! This program will determine if a sequence of digits is a palindrome or not.")
print("Enter a sequence of digits (0 through 9) one after the other, enter a -1 when done.")
n = int(input("Enter a number: "))
while n != -1:
list.append(n)
n = int(input("Enter a number: "))


seq = []
getInput(seq)
print(seq)
# e.g.: a sequence of 1 0 5 1 -1
# gives: seq = [1,0,5,1]

####### YOUR CODE GOES BELOW ###############################


# NOTE: You are NOT allowed to use any loops in the code that you write. Writing a loop will result in a score of zero. Your solution MUST be recursive.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!