Python Write Recursive Function Called Ismirror Takes Three Input Values List Numbers Inde Q37219414

Python

Write a recursive function called “is_mirror“which takes THREE input values:

  1. a list of numbers
  2. the index position of the first item in thelist
  3. the index position of the last item in thelist

Your function should return True if the valuesbetween (and including) the first and last indexpositions form a “mirror”.


Answer


def is_mirror(numbers, first, last): if first < last: if numbers[first] != numbers[last]: return False return is_mirror(numbers, first + 1, last – 1)

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.