Check if List is Palindrome

Advanced

Check if List is Palindrome

In this challenge, you need to create a function called is_list_palindrome that checks if a given list of numbers is a palindrome. A palindrome is a sequence that reads the same forwards and backwards.

Your task is to determine if the list is a palindrome or not.

Examples

  • When the input is [1, 2, 3, 2, 1], the list reads the same forwards and backwards, so the function should return True.

  • For the input [1, 2, 3, 4, 5], the list is not the same forwards and backwards, so the function should return False.

  • An empty list [] or a list with one element [7] is always a palindrome, so the function should return True in both cases.

Here's how you can think about the problem:

  • Compare the list with its reverse.
  • If both are the same, then the list is a palindrome.
is_list_palindrome([1, 2, 3, 2, 1]) # True is_list_palindrome([1, 2, 3, 4, 5]) # False is_list_palindrome([]) # True is_list_palindrome([7]) # True

It's a fun and simple way to learn about lists and palindromic concepts!

Good luck, and may your list sequences be ever the same backward and forward!

Geek
Inputs

Arg 1:

[1,2,3,2,1]
Expected Output
true
Actual Output
Check if List is Palindrome [advanced] | Coding for Kids