-1

I was solving the problem at Codesignal and saw one of the solutions that check palindrome like this.

def checkPalindrome(inputString):
    return inputString == inputString[::-1]

How is that working? Please explain what is going on here.

Capz
  • 9

1 Answers1

1

inputString[::-1] returns the reverse of inputString. A palindrome is the same word spelled backwards and forwards, and that's what the equality operator checks.

user2233706
  • 6,148
  • 5
  • 44
  • 86