170k views
3 votes
Write the definition of a function, is_reverse, whose two parameters are arrays of integers of equal size. The function returns true if and only if one array is the reverse of the other. ("Reverse" here means same elements but in reverse order.)

User Vladimir T
by
5.0k points

1 Answer

2 votes

Answer:

def is_reverse(lst1, lst2):

lst2 = lst2[::-1]

if lst1 == lst2:

return True

else:

return False

Step-by-step explanation:

Create a function called is_reverse that takes two parameters, lst1 and lst2

Reverse the second list using slicing

Check if the first list and the second list are equal to each other. If they are, return True. Otherwise, return False

User Moffeltje
by
5.0k points